Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

fix: capture shots in `FewShotGenerator` in metadata (#2159)

hallerite17316d4421d3
diff --git a/camel/datasets/few_shot_generator.py b/camel/datasets/few_shot_generator.py
index 45d4daf6d..f215361a0 100644
--- a/camel/datasets/few_shot_generator.py
+++ b/camel/datasets/few_shot_generator.py
@@ -235,6 +235,7 @@ class FewShotGenerator(BaseGenerator):
"synthetic": str(True),
"created": datetime.now().isoformat(),
"generator": "few_shot",
+ "shots": [e.to_dict() for e in examples],
},
)
except ValidationError as e:
diff --git a/camel/environments/single_step.py b/camel/environments/single_step.py
index 3e7d65cb4..fd8547d4b 100644
--- a/camel/environments/single_step.py
+++ b/camel/environments/single_step.py
@@ -200,7 +200,13 @@ class SingleStepEnv:
self._states_done = [False] * self.current_batch_size
observations = [
- Observation(question=sample.question, context={}, metadata={})
+ Observation(
+ question=sample.question,
+ context={},
+ metadata=sample.metadata
+ if sample.metadata is not None
+ else {},
+ )
for sample in self._states
]
@@ -214,7 +220,13 @@ class SingleStepEnv:
self._states_done = [False] * batch_size
observations = [
- Observation(question=sample.question, context={}, metadata={})
+ Observation(
+ question=sample.question,
+ context={},
+ metadata=sample.metadata
+ if sample.metadata is not None
+ else {},
+ )
for sample in self._states
]
diff --git a/examples/dataset/few_shot_generator.py b/examples/dataset/few_shot_generator.py
index dff711036..8fa006f5e 100644
--- a/examples/dataset/few_shot_generator.py
+++ b/examples/dataset/few_shot_generator.py
@@ -27,7 +27,7 @@ from camel.verifiers import PythonVerifier
logger = get_logger(__name__)
verifier = PythonVerifier(required_packages=["sympy"])
-asyncio.run(verifier.setup())
+asyncio.run(verifier.setup(uv=True))
raw_data2 = [
{
@@ -85,9 +85,6 @@ generator = FewShotGenerator(
new_data = asyncio.run(generator.generate_new(n=2, max_retries=5))
-for dp in new_data:
- print(dp)
-
generator.save_to_jsonl(Path("generated_data.jsonl"))
asyncio.run(verifier.cleanup())