Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Raise error if data is not example but passes input optim in config

Herumb Shandilya6295d98b2cf9
diff --git a/dspy/experimental/synthesizer/synthesizer.py b/dspy/experimental/synthesizer/synthesizer.py
index 0672a2808..bd70e6d7a 100644
--- a/dspy/experimental/synthesizer/synthesizer.py
+++ b/dspy/experimental/synthesizer/synthesizer.py
@@ -202,7 +202,9 @@ class Synthesizer:
}
if self.config.num_example_for_optim:
- kwargs["ground_source"] = random.sample(ground_source, self.config.num_example_for_optim)
+ if not isinstance(ground_source, list):
+ raise ValueError("Ground source must be a list of examples when `num_example_for_optim` is provided.")
+ kwargs["ground_source"] = random.sample(ground_source, k=self.config.num_example_for_optim)
with dspy.context(lm=self.input_lm):
inputs = self.input_predictor(**kwargs)