Generalize the get_item method to all CompletionDatasets

This commit is contained in:
Chime Ogbuji 2024-12-09 11:46:00 -05:00 committed by Awni Hannun
parent 7989d0a874
commit b9748e9ee4

View File

@ -108,6 +108,14 @@ class CompletionsDatasetCollection:
return self.__fetch_and_process_item__(idx, getitem)
def get_item(
self, idx: int, tokenize: bool = False, add_generation_prompt: bool = True
) -> str:
def getitem(dataset: CompletionsDataset, index: int):
return dataset.get_item(index, tokenize, add_generation_prompt)
return self.__fetch_and_process_item__(idx, getitem)
def get_prompt_and_completion(self, idx: int):
def getitem(dataset: CompletionsDataset, index: int):
return dataset.get_prompt_and_completion(index)