camel-ai 0.2.29__tar.gz → 0.2.30__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of camel-ai might be problematic. Click here for more details.
- {camel_ai-0.2.29 → camel_ai-0.2.30}/PKG-INFO +2 -1
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/__init__.py +1 -1
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datasets/__init__.py +7 -5
- camel_ai-0.2.30/camel/datasets/base_generator.py +335 -0
- camel_ai-0.2.30/camel/datasets/models.py +61 -0
- camel_ai-0.2.30/camel/datasets/static_dataset.py +346 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/openai_compatible_embedding.py +4 -4
- camel_ai-0.2.30/camel/environments/__init__.py +25 -0
- camel_ai-0.2.30/camel/environments/models.py +111 -0
- camel_ai-0.2.30/camel/environments/multi_step.py +271 -0
- camel_ai-0.2.30/camel/environments/single_step.py +293 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/logger.py +56 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/openai_compatible_model.py +4 -2
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/browser_toolkit.py +59 -1
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/search_toolkit.py +70 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/utils/commons.py +1 -1
- {camel_ai-0.2.29 → camel_ai-0.2.30}/pyproject.toml +2 -1
- camel_ai-0.2.29/camel/datasets/base.py +0 -639
- camel_ai-0.2.29/camel/environments/__init__.py +0 -16
- camel_ai-0.2.29/camel/environments/base.py +0 -509
- {camel_ai-0.2.29 → camel_ai-0.2.30}/.gitignore +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/LICENSE +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/README.md +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/_types.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/_utils.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/chat_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/critic_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/deductive_reasoner_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/embodied_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/knowledge_graph_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/multi_hop_generator_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/programmed_agent_instruction.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/role_assignment_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/search_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/task_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/tool_agents/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/tool_agents/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/agents/tool_agents/hugging_face_tool_agent.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/benchmarks/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/benchmarks/apibank.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/benchmarks/apibench.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/benchmarks/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/benchmarks/gaia.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/benchmarks/nexus.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/benchmarks/ragbench.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/discord/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/discord/discord_app.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/discord/discord_installation.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/discord/discord_store.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/slack/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/slack/models.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/slack/slack_app.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/bots/telegram_bot.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/aiml_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/anthropic_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/base_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/cohere_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/deepseek_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/gemini_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/groq_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/internlm_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/litellm_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/mistral_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/moonshot_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/nvidia_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/ollama_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/openai_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/qwen_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/reka_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/samba_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/sglang_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/siliconflow_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/togetherai_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/vllm_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/yi_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/configs/zhipuai_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/data_collector/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/data_collector/alpaca_collector.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/data_collector/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/data_collector/sharegpt_collector.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/cot_datagen.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_improving_cot.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_instruct/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_instruct/filter/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_instruct/filter/filter_function.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_instruct/filter/filter_registry.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_instruct/filter/instruction_filter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_instruct/self_instruct.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/self_instruct/templates.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/source2synth/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/source2synth/data_processor.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/source2synth/models.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datagen/source2synth/user_data_processor_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datahubs/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datahubs/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datahubs/huggingface.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/datahubs/models.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/jina_embedding.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/mistral_embedding.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/openai_embedding.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/sentence_transformers_embeddings.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/embeddings/vlm_embedding.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/extractors/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/extractors/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/extractors/python_strategies.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/generators.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/human.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/docker/Dockerfile +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/docker_interpreter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/e2b_interpreter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/internal_python_interpreter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/interpreter_error.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/ipython_interpreter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/interpreters/subprocess_interpreter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/apify_reader.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/base_io.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/chunkr_reader.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/firecrawl_reader.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/jina_url_reader.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/mineru_extractor.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/panda_reader.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/loaders/unstructured_io.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/agent_memories.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/blocks/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/blocks/chat_history_block.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/blocks/vectordb_block.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/context_creators/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/context_creators/score_based.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/memories/records.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/conversion/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/conversion/alpaca.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/conversion/conversation_models.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/conversion/sharegpt/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/conversion/sharegpt/function_call_formatter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/conversion/sharegpt/hermes/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/conversion/sharegpt/hermes/hermes_function_formatter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/messages/func_message.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/_utils.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/aiml_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/anthropic_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/azure_openai_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/base_audio_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/base_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/cohere_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/deepseek_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/fish_audio_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/gemini_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/groq_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/internlm_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/litellm_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/mistral_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/model_factory.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/model_manager.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/moonshot_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/nemotron_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/nvidia_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/ollama_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/openai_audio_models.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/openai_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/qwen_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/reka_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/reward/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/reward/base_reward_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/reward/evaluator.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/reward/nemotron_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/reward/skywork_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/samba_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/sglang_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/siliconflow_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/stub_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/togetherai_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/vllm_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/volcano_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/yi_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/models/zhipuai_model.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/personas/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/personas/persona.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/personas/persona_hub.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/ai_society.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/code.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/evaluation.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/generate_text_embedding_data.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/image_craft.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/misalignment.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/multi_condition_image_craft.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/object_recognition.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/persona_hub.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/prompt_templates.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/role_description_prompt_template.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/solution_extraction.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/task_prompt_template.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/translation.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/prompts/video_description_prompt.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/py.typed +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/responses/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/responses/agent_responses.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/retrievers/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/retrievers/auto_retriever.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/retrievers/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/retrievers/bm25_retriever.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/retrievers/cohere_rerank_retriever.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/retrievers/hybrid_retrival.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/retrievers/vector_retriever.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/api.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/configs.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/docker_runtime.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/llm_guard_runtime.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/remote_http_runtime.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/utils/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/utils/function_risk_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/runtime/utils/ignore_risk_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/schemas/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/schemas/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/schemas/openai_converter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/schemas/outlines_converter.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/babyagi_playing.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/role_playing.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/prompts.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/role_playing_worker.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/single_agent_worker.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/task_channel.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/utils.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/worker.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/societies/workforce/workforce.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/graph_storages/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/graph_storages/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/graph_storages/graph_element.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/graph_storages/nebula_graph.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/graph_storages/neo4j_graph.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/key_value_storages/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/key_value_storages/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/key_value_storages/in_memory.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/key_value_storages/json.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/key_value_storages/redis.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/object_storages/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/object_storages/amazon_s3.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/object_storages/azure_blob.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/object_storages/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/object_storages/google_cloud.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/vectordb_storages/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/vectordb_storages/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/vectordb_storages/milvus.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/storages/vectordb_storages/qdrant.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/tasks/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/tasks/task.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/tasks/task_prompt.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/terminators/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/terminators/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/terminators/response_terminator.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/terminators/token_limit_terminator.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/arxiv_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/ask_news_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/audio_analysis_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/code_execution.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/dalle_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/dappier_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/data_commons_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/excel_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/file_write_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/function_tool.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/github_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/google_maps_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/google_scholar_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/human_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/image_analysis_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/linkedin_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/math_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/mcp_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/meshy_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/mineru_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/networkx_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/notion_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/biztoc/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/biztoc/ai-plugin.json +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/biztoc/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/coursera/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/coursera/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/create_qr_code/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/create_qr_code/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/klarna/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/klarna/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/nasa_apod/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/nasa_apod/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/outschool/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/outschool/ai-plugin.json +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/outschool/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/outschool/paths/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/outschool/paths/get_classes.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/outschool/paths/search_teachers.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/security_config.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/speak/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/speak/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/web_scraper/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/web_scraper/ai-plugin.json +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/web_scraper/openapi.yaml +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/web_scraper/paths/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_specs/web_scraper/paths/scraper.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/open_api_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/openbb_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/page_script.js +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/pubmed_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/reddit_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/retrieval_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/semantic_scholar_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/slack_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/stripe_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/sympy_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/terminal_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/twitter_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/video_analysis_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/video_download_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/weather_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/whatsapp_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/toolkits/zapier_toolkit.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/types/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/types/agents/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/types/agents/tool_calling_record.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/types/enums.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/types/openai_types.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/types/unified_model_type.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/utils/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/utils/async_func.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/utils/constants.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/utils/deduplication.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/utils/response_format.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/utils/token_counting.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/verifiers/__init__.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/verifiers/base.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/verifiers/models.py +0 -0
- {camel_ai-0.2.29 → camel_ai-0.2.30}/camel/verifiers/python_verifier.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: camel-ai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.30
|
|
4
4
|
Summary: Communicative Agents for AI Society Study
|
|
5
5
|
Project-URL: Homepage, https://www.camel-ai.org/
|
|
6
6
|
Project-URL: Repository, https://github.com/camel-ai/camel
|
|
@@ -239,6 +239,7 @@ Requires-Dist: pytest-asyncio<0.24,>=0.23.0; extra == 'test'
|
|
|
239
239
|
Requires-Dist: pytest<8,>=7; extra == 'test'
|
|
240
240
|
Provides-Extra: web-tools
|
|
241
241
|
Requires-Dist: apify-client<2,>=1.8.1; extra == 'web-tools'
|
|
242
|
+
Requires-Dist: beautifulsoup4<5,>=4; extra == 'web-tools'
|
|
242
243
|
Requires-Dist: dappier<0.4,>=0.3.3; extra == 'web-tools'
|
|
243
244
|
Requires-Dist: duckduckgo-search<7,>=6.3.5; extra == 'web-tools'
|
|
244
245
|
Requires-Dist: fastapi>=0.115.11; extra == 'web-tools'
|
|
@@ -11,14 +11,16 @@
|
|
|
11
11
|
# See the License for the specific language governing permissions and
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
|
-
from .
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
StaticDataset,
|
|
14
|
+
from .base_generator import (
|
|
15
|
+
BaseGenerator,
|
|
16
|
+
FewShotGenerator,
|
|
18
17
|
)
|
|
18
|
+
from .models import DataPoint
|
|
19
|
+
from .static_dataset import StaticDataset
|
|
19
20
|
|
|
20
21
|
__all__ = [
|
|
22
|
+
"BaseGenerator",
|
|
21
23
|
"DataPoint",
|
|
24
|
+
"FewShotGenerator",
|
|
22
25
|
"StaticDataset",
|
|
23
|
-
"GenerativeDataset",
|
|
24
26
|
]
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
|
+
|
|
15
|
+
import abc
|
|
16
|
+
import json
|
|
17
|
+
import random
|
|
18
|
+
from datetime import datetime
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from typing import (
|
|
21
|
+
List,
|
|
22
|
+
Union,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
from pydantic import ValidationError
|
|
26
|
+
|
|
27
|
+
from camel.agents import ChatAgent
|
|
28
|
+
from camel.logger import get_logger
|
|
29
|
+
from camel.verifiers import BaseVerifier
|
|
30
|
+
from camel.verifiers.models import VerifierInput
|
|
31
|
+
|
|
32
|
+
from .models import DataPoint
|
|
33
|
+
from .static_dataset import StaticDataset
|
|
34
|
+
|
|
35
|
+
logger = get_logger(__name__)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class BaseGenerator(abc.ABC):
|
|
39
|
+
r"""Abstract base class for data generators.
|
|
40
|
+
|
|
41
|
+
This class defines the interface for generating synthetic datapoints.
|
|
42
|
+
Concrete implementations should provide specific generation strategies.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, seed: int = 42, **kwargs):
|
|
46
|
+
r"""Initialize the base generator.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
seed (int): Random seed for reproducibility. (default: :obj:`42`)
|
|
50
|
+
**kwargs: Additional generator parameters.
|
|
51
|
+
"""
|
|
52
|
+
self._rng = random.Random(seed)
|
|
53
|
+
|
|
54
|
+
self._data: List[DataPoint] = []
|
|
55
|
+
|
|
56
|
+
@abc.abstractmethod
|
|
57
|
+
async def generate_new(self, n: int, **kwargs) -> List[DataPoint]:
|
|
58
|
+
r"""Generate n new datapoints.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
n (int): Number of datapoints to generate.
|
|
62
|
+
**kwargs: Additional generation parameters.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
List[DataPoint]: A list of newly generated datapoints.
|
|
66
|
+
"""
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
def __len__(self) -> int:
|
|
70
|
+
r"""Return the size of the generated dataset."""
|
|
71
|
+
return len(self._data)
|
|
72
|
+
|
|
73
|
+
def __getitem__(self, idx: int) -> DataPoint:
|
|
74
|
+
r"""Retrieve a datapoint by index.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
idx (int): Index of the datapoint.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
DataPoint: The datapoint corresponding to the given index.
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
IndexError: If idx is out of bounds.
|
|
84
|
+
"""
|
|
85
|
+
if idx < 0 or idx >= len(self._data):
|
|
86
|
+
raise IndexError(
|
|
87
|
+
f"Index {idx} out of bounds for dataset of "
|
|
88
|
+
f"size {len(self._data)}"
|
|
89
|
+
)
|
|
90
|
+
return self._data[idx]
|
|
91
|
+
|
|
92
|
+
def sample(self) -> DataPoint:
|
|
93
|
+
if len(self._data) == 0:
|
|
94
|
+
raise RuntimeError("Dataset is empty, cannot sample.")
|
|
95
|
+
idx = self._rng.randint(0, len(self._data) - 1)
|
|
96
|
+
return self[idx]
|
|
97
|
+
|
|
98
|
+
def save_to_jsonl(self, file_path: Union[str, Path]) -> None:
|
|
99
|
+
r"""Saves the generated datapoints to a JSONL (JSON Lines) file.
|
|
100
|
+
|
|
101
|
+
Each datapoint is stored as a separate JSON object on a new line.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
file_path (Union[str, Path]): Path to save the JSONL file.
|
|
105
|
+
|
|
106
|
+
Raises:
|
|
107
|
+
ValueError: If no datapoints have been generated.
|
|
108
|
+
IOError: If there is an issue writing to the file.
|
|
109
|
+
|
|
110
|
+
Notes:
|
|
111
|
+
- Uses `self._data`, which contains the generated datapoints.
|
|
112
|
+
- Overwrites the file if it already exists.
|
|
113
|
+
- Ensures compatibility with large datasets by using JSONL format.
|
|
114
|
+
"""
|
|
115
|
+
if not self._data:
|
|
116
|
+
raise ValueError("Dataset is empty. No data to save.")
|
|
117
|
+
|
|
118
|
+
file_path = Path(file_path)
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
with file_path.open("w", encoding="utf-8") as f:
|
|
122
|
+
for datapoint in self._data:
|
|
123
|
+
json.dump(datapoint.to_dict(), f)
|
|
124
|
+
f.write("\n") # Ensure each entry is on a new line
|
|
125
|
+
logger.info(f"Dataset saved successfully to {file_path}")
|
|
126
|
+
except IOError as e:
|
|
127
|
+
logger.error(f"Error writing to file {file_path}: {e}")
|
|
128
|
+
raise
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class FewShotGenerator(BaseGenerator):
|
|
132
|
+
r"""A generator for creating synthetic datapoints using few-shot learning.
|
|
133
|
+
|
|
134
|
+
This class leverages a seed dataset, an agent, and a verifier to generate
|
|
135
|
+
new synthetic datapoints on demand through few-shot prompting.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
def __init__(
|
|
139
|
+
self,
|
|
140
|
+
seed_dataset: StaticDataset,
|
|
141
|
+
verifier: BaseVerifier,
|
|
142
|
+
agent: ChatAgent,
|
|
143
|
+
seed: int = 42,
|
|
144
|
+
**kwargs,
|
|
145
|
+
):
|
|
146
|
+
r"""Initialize the few-shot generator.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
seed_dataset (StaticDataset): Validated static dataset to
|
|
150
|
+
use for examples.
|
|
151
|
+
verifier (BaseVerifier): Verifier to validate generated content.
|
|
152
|
+
agent (ChatAgent): Agent to generate new datapoints.
|
|
153
|
+
seed (int): Random seed for reproducibility. (default: :obj:`42`)
|
|
154
|
+
**kwargs: Additional generator parameters.
|
|
155
|
+
"""
|
|
156
|
+
super().__init__(seed=seed, **kwargs)
|
|
157
|
+
self.seed_dataset = seed_dataset
|
|
158
|
+
try:
|
|
159
|
+
self._validate_seed_dataset()
|
|
160
|
+
except Exception:
|
|
161
|
+
raise RuntimeError("Seed Data does not follow Datapoint format")
|
|
162
|
+
self.verifier = verifier
|
|
163
|
+
self.agent = agent
|
|
164
|
+
|
|
165
|
+
# TODO: Validate that seed dataset contains rationale
|
|
166
|
+
def _validate_seed_dataset(self) -> None:
|
|
167
|
+
pass
|
|
168
|
+
|
|
169
|
+
def _construct_prompt(self, examples: List[DataPoint]) -> str:
|
|
170
|
+
r"""Construct a prompt for generating new datapoints
|
|
171
|
+
using a fixed sample of examples from the seed dataset.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
examples (List[DataPoint]): Examples to include in the prompt.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
str: Formatted prompt with examples.
|
|
178
|
+
"""
|
|
179
|
+
prompt = (
|
|
180
|
+
"Generate a new datapoint similar to the following examples:\n\n"
|
|
181
|
+
)
|
|
182
|
+
for i, example in enumerate(examples, 1):
|
|
183
|
+
prompt += f"Example {i}:\n"
|
|
184
|
+
prompt += f"Question: {example.question}\n"
|
|
185
|
+
if example.rationale is not None:
|
|
186
|
+
prompt += f"Rationale: {example.rationale}\n"
|
|
187
|
+
else:
|
|
188
|
+
prompt += "Rationale: None\n"
|
|
189
|
+
prompt += f"Final Answer: {example.final_answer}\n\n"
|
|
190
|
+
prompt += "New datapoint:"
|
|
191
|
+
return prompt
|
|
192
|
+
|
|
193
|
+
async def generate_new(
|
|
194
|
+
self,
|
|
195
|
+
n: int,
|
|
196
|
+
max_retries: int = 10,
|
|
197
|
+
num_examples: int = 3,
|
|
198
|
+
**kwargs,
|
|
199
|
+
) -> List[DataPoint]:
|
|
200
|
+
r"""Generates and validates `n` new datapoints through
|
|
201
|
+
few-shot prompting, with a retry limit.
|
|
202
|
+
|
|
203
|
+
Steps:
|
|
204
|
+
1. Samples examples from the seed dataset.
|
|
205
|
+
2. Constructs a prompt using the selected examples.
|
|
206
|
+
3. Uses an agent to generate a new datapoint,
|
|
207
|
+
consisting of a question and code to solve the question.
|
|
208
|
+
4. Executes code using a verifier to get pseudo ground truth.
|
|
209
|
+
5. Stores valid datapoints in memory.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
n (int): Number of valid datapoints to generate.
|
|
213
|
+
max_retries (int): Maximum number of retries before stopping.
|
|
214
|
+
(default: :obj:`10`)
|
|
215
|
+
num_examples (int): Number of examples to sample from the
|
|
216
|
+
seed dataset for few shot prompting.
|
|
217
|
+
(default: :obj:`3`)
|
|
218
|
+
**kwargs: Additional generation parameters.
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
List[DataPoint]: A list of newly generated valid datapoints.
|
|
222
|
+
|
|
223
|
+
Raises:
|
|
224
|
+
TypeError: If the agent's output is not a dictionary (or does not
|
|
225
|
+
match the expected format).
|
|
226
|
+
KeyError: If required keys are missing from the response.
|
|
227
|
+
AttributeError: If the verifier response lacks attributes.
|
|
228
|
+
ValidationError: If a datapoint fails schema validation.
|
|
229
|
+
RuntimeError: If retries are exhausted before `n` valid datapoints
|
|
230
|
+
are generated.
|
|
231
|
+
|
|
232
|
+
Notes:
|
|
233
|
+
- Retries on validation failures until `n` valid datapoints exist
|
|
234
|
+
or `max_retries` is reached, whichever comes first.
|
|
235
|
+
- If retries are exhausted before reaching `n`, a `RuntimeError`
|
|
236
|
+
is raised.
|
|
237
|
+
- Metadata includes a timestamp for tracking datapoint creation.
|
|
238
|
+
"""
|
|
239
|
+
valid_data_points: List[DataPoint] = []
|
|
240
|
+
retries = 0
|
|
241
|
+
|
|
242
|
+
while len(valid_data_points) < n and retries < max_retries:
|
|
243
|
+
try:
|
|
244
|
+
examples = [
|
|
245
|
+
self.seed_dataset.sample() for _ in range(num_examples)
|
|
246
|
+
]
|
|
247
|
+
prompt = self._construct_prompt(examples)
|
|
248
|
+
|
|
249
|
+
try:
|
|
250
|
+
agent_output = (
|
|
251
|
+
self.agent.step(prompt, response_format=DataPoint)
|
|
252
|
+
.msgs[0]
|
|
253
|
+
.parsed
|
|
254
|
+
)
|
|
255
|
+
if not isinstance(agent_output, dict):
|
|
256
|
+
raise TypeError("Agent output must be a dictionary")
|
|
257
|
+
if "question" not in agent_output:
|
|
258
|
+
raise KeyError(
|
|
259
|
+
"Missing 'question' in agent"
|
|
260
|
+
f"output {agent_output}"
|
|
261
|
+
)
|
|
262
|
+
if "rationale" not in agent_output:
|
|
263
|
+
raise KeyError(
|
|
264
|
+
"Missing 'rationale' in agent"
|
|
265
|
+
f"output {agent_output}"
|
|
266
|
+
)
|
|
267
|
+
except (TypeError, KeyError) as e:
|
|
268
|
+
logger.warning(
|
|
269
|
+
f"Agent output issue: {e}, retrying... "
|
|
270
|
+
f"({retries + 1}/{max_retries})"
|
|
271
|
+
)
|
|
272
|
+
retries += 1
|
|
273
|
+
continue
|
|
274
|
+
|
|
275
|
+
rationale = agent_output.get("rationale")
|
|
276
|
+
|
|
277
|
+
if not isinstance(rationale, str):
|
|
278
|
+
raise TypeError(f"Rationale {rationale} is not a string.")
|
|
279
|
+
|
|
280
|
+
try:
|
|
281
|
+
verifier_response = await self.verifier.verify(
|
|
282
|
+
VerifierInput(
|
|
283
|
+
llm_response=rationale,
|
|
284
|
+
ground_truth=None,
|
|
285
|
+
)
|
|
286
|
+
)
|
|
287
|
+
if not verifier_response or not verifier_response.result:
|
|
288
|
+
raise ValueError(
|
|
289
|
+
"Verifier unsuccessful, response: "
|
|
290
|
+
f"{verifier_response}"
|
|
291
|
+
)
|
|
292
|
+
except (ValueError, AttributeError) as e:
|
|
293
|
+
logger.warning(
|
|
294
|
+
f"Verifier issue: {e}, "
|
|
295
|
+
f"retrying... ({retries + 1}/{max_retries})"
|
|
296
|
+
)
|
|
297
|
+
retries += 1
|
|
298
|
+
continue
|
|
299
|
+
|
|
300
|
+
try:
|
|
301
|
+
new_datapoint = DataPoint(
|
|
302
|
+
question=agent_output["question"],
|
|
303
|
+
rationale=rationale,
|
|
304
|
+
final_answer=verifier_response.result,
|
|
305
|
+
metadata={
|
|
306
|
+
"synthetic": str(True),
|
|
307
|
+
"created": datetime.now().isoformat(),
|
|
308
|
+
"generator": "few_shot",
|
|
309
|
+
},
|
|
310
|
+
)
|
|
311
|
+
except ValidationError as e:
|
|
312
|
+
logger.warning(
|
|
313
|
+
f"Datapoint validation failed: {e}, "
|
|
314
|
+
f"retrying... ({retries + 1}/{max_retries})"
|
|
315
|
+
)
|
|
316
|
+
retries += 1
|
|
317
|
+
continue
|
|
318
|
+
|
|
319
|
+
valid_data_points.append(new_datapoint)
|
|
320
|
+
|
|
321
|
+
except Exception as e:
|
|
322
|
+
logger.warning(
|
|
323
|
+
f"Unexpected error: {e}, retrying..."
|
|
324
|
+
f" ({retries + 1}/{max_retries})"
|
|
325
|
+
)
|
|
326
|
+
retries += 1
|
|
327
|
+
|
|
328
|
+
if len(valid_data_points) < n:
|
|
329
|
+
raise RuntimeError(
|
|
330
|
+
f"Failed to generate {n} valid datapoints "
|
|
331
|
+
f"after {max_retries} retries."
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
self._data.extend(valid_data_points)
|
|
335
|
+
return valid_data_points
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
|
+
from typing import Any, Dict, Optional
|
|
15
|
+
|
|
16
|
+
from pydantic import BaseModel, Field
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DataPoint(BaseModel):
|
|
20
|
+
r"""A single data point in the dataset.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
question (str): The primary question or issue to be addressed.
|
|
24
|
+
final_answer (str): The final answer.
|
|
25
|
+
rationale (Optional[str]): Logical reasoning or explanation behind the
|
|
26
|
+
answer. (default: :obj:`None`)
|
|
27
|
+
metadata Optional[Dict[str, Any]]: Additional metadata about the data
|
|
28
|
+
point. (default: :obj:`None`)
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
question: str = Field(
|
|
32
|
+
..., description="The primary question or issue to be addressed."
|
|
33
|
+
)
|
|
34
|
+
final_answer: str = Field(..., description="The final answer.")
|
|
35
|
+
rationale: Optional[str] = Field(
|
|
36
|
+
default=None,
|
|
37
|
+
description="Logical reasoning or explanation behind the answer.",
|
|
38
|
+
)
|
|
39
|
+
metadata: Optional[Dict[str, Any]] = Field(
|
|
40
|
+
default=None, description="Additional metadata about the data point."
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
44
|
+
r"""Convert DataPoint to a dictionary.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Dict[str, Any]: Dictionary representation of the DataPoint.
|
|
48
|
+
"""
|
|
49
|
+
return self.dict()
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_dict(cls, data: Dict[str, Any]) -> 'DataPoint':
|
|
53
|
+
r"""Create a DataPoint from a dictionary.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
data (Dict[str, Any]): Dictionary containing DataPoint fields.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
DataPoint: New DataPoint instance.
|
|
60
|
+
"""
|
|
61
|
+
return cls(**data)
|