Skip to content

Commit

Permalink
revert to python types and remove conflics
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHWade committed Mar 4, 2024
1 parent 2bd6fda commit 910606a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dspy/datasets/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ def from_json(self, file_path:str, fields: List[str] = None, input_keys: Tuple[s

return [dspy.Example({field:row[field] for field in fields}).with_inputs(*input_keys) for row in dataset]

def from_parquet(self, file_path: str, fields: List[str] = None, input_keys: Tuple[str] = ()) -> List[dspy.Example]:
dataset = load_dataset("parquet", data_files=file_path)["train"]

if not fields:
fields = list(dataset.features)

return [dspy.Example({field: row[field] for field in fields}).with_inputs(input_keys) for row in dataset]

def sample(
self,
dataset: List[dspy.Example],
Expand Down Expand Up @@ -110,4 +117,4 @@ def train_test_split(
train_dataset = dataset_shuffled[:train_end]
test_dataset = dataset_shuffled[train_end:train_end + test_end]

return {'train': train_dataset, 'test': test_dataset}
return {'train': train_dataset, 'test': test_dataset}

0 comments on commit 910606a

Please sign in to comment.