camel-ai 0.2.19__tar.gz → 0.2.20a1__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.19 → camel_ai-0.2.20a1}/PKG-INFO +5 -2
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/README.md +4 -1
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/__init__.py +1 -1
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/chat_agent.py +27 -27
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/__init__.py +6 -0
- camel_ai-0.2.20a1/camel/configs/moonshot_config.py +63 -0
- camel_ai-0.2.20a1/camel/configs/siliconflow_config.py +91 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datahubs/huggingface.py +3 -3
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/jina_embedding.py +6 -1
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/__init__.py +2 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/model_factory.py +6 -0
- camel_ai-0.2.20a1/camel/models/moonshot_model.py +138 -0
- camel_ai-0.2.20a1/camel/models/siliconflow_model.py +142 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/__init__.py +2 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/search_toolkit.py +12 -0
- camel_ai-0.2.20a1/camel/toolkits/semantic_scholar_toolkit.py +308 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/types/enums.py +112 -5
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/types/unified_model_type.py +5 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/pyproject.toml +1 -1
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/LICENSE +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/critic_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/deductive_reasoner_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/embodied_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/knowledge_graph_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/multi_hop_generator_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/programmed_agent_instruction.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/role_assignment_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/search_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/task_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/tool_agents/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/tool_agents/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/agents/tool_agents/hugging_face_tool_agent.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/benchmarks/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/benchmarks/apibank.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/benchmarks/apibench.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/benchmarks/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/benchmarks/gaia.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/benchmarks/nexus.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/benchmarks/ragbench.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/discord/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/discord/discord_app.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/discord/discord_installation.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/discord/discord_store.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/slack/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/slack/models.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/slack/slack_app.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/bots/telegram_bot.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/anthropic_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/base_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/cohere_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/deepseek_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/gemini_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/groq_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/internlm_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/litellm_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/mistral_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/nvidia_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/ollama_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/openai_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/qwen_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/reka_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/samba_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/sglang_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/togetherai_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/vllm_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/yi_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/configs/zhipuai_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/data_collector/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/data_collector/alpaca_collector.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/data_collector/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/data_collector/sharegpt_collector.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/cotdatagen.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/self_instruct/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/self_instruct/filter/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/self_instruct/filter/filter_function.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/self_instruct/filter/filter_registry.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/self_instruct/filter/instruction_filter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/self_instruct/self_instruct.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/self_instruct/templates.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/source2synth/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/source2synth/data_processor.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/source2synth/models.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datagen/source2synth/user_data_processor_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datahubs/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datahubs/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/datahubs/models.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/mistral_embedding.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/openai_compatible_embedding.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/openai_embedding.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/sentence_transformers_embeddings.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/embeddings/vlm_embedding.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/generators.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/human.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/docker_interpreter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/e2b_interpreter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/internal_python_interpreter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/interpreter_error.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/ipython_interpreter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/interpreters/subprocess_interpreter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/apify_reader.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/base_io.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/chunkr_reader.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/firecrawl_reader.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/jina_url_reader.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/panda_reader.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/loaders/unstructured_io.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/logger.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/agent_memories.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/blocks/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/blocks/chat_history_block.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/blocks/vectordb_block.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/context_creators/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/context_creators/score_based.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/memories/records.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/conversion/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/conversion/alpaca.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/conversion/conversation_models.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/conversion/sharegpt/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/conversion/sharegpt/function_call_formatter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/conversion/sharegpt/hermes/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/conversion/sharegpt/hermes/hermes_function_formatter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/messages/func_message.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/anthropic_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/azure_openai_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/base_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/cohere_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/deepseek_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/fish_audio_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/gemini_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/groq_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/internlm_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/litellm_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/mistral_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/model_manager.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/nemotron_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/nvidia_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/ollama_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/openai_audio_models.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/openai_compatible_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/openai_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/qwen_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/reka_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/reward/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/reward/base_reward_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/reward/evaluator.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/reward/nemotron_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/reward/skywork_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/samba_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/sglang_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/stub_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/togetherai_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/vllm_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/yi_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/models/zhipuai_model.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/personas/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/personas/persona.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/personas/persona_hub.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/ai_society.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/code.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/evaluation.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/generate_text_embedding_data.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/image_craft.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/misalignment.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/multi_condition_image_craft.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/object_recognition.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/persona_hub.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/prompt_templates.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/role_description_prompt_template.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/solution_extraction.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/task_prompt_template.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/translation.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/prompts/video_description_prompt.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/responses/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/responses/agent_responses.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/retrievers/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/retrievers/auto_retriever.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/retrievers/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/retrievers/bm25_retriever.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/retrievers/cohere_rerank_retriever.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/retrievers/vector_retriever.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/api.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/configs.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/docker_runtime.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/llm_guard_runtime.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/remote_http_runtime.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/utils/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/utils/function_risk_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/runtime/utils/ignore_risk_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/schemas/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/schemas/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/schemas/openai_converter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/schemas/outlines_converter.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/babyagi_playing.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/role_playing.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/prompts.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/role_playing_worker.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/single_agent_worker.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/task_channel.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/utils.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/worker.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/societies/workforce/workforce.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/graph_storages/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/graph_storages/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/graph_storages/graph_element.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/graph_storages/nebula_graph.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/graph_storages/neo4j_graph.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/key_value_storages/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/key_value_storages/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/key_value_storages/in_memory.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/key_value_storages/json.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/key_value_storages/redis.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/object_storages/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/object_storages/amazon_s3.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/object_storages/azure_blob.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/object_storages/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/object_storages/google_cloud.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/vectordb_storages/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/vectordb_storages/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/vectordb_storages/milvus.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/storages/vectordb_storages/qdrant.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/tasks/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/tasks/task.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/tasks/task_prompt.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/terminators/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/terminators/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/terminators/response_terminator.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/terminators/token_limit_terminator.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/arxiv_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/ask_news_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/base.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/code_execution.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/dalle_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/dappier_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/data_commons_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/function_tool.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/github_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/google_maps_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/google_scholar_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/human_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/linkedin_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/math_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/meshy_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/notion_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/biztoc/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/biztoc/ai-plugin.json +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/biztoc/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/coursera/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/coursera/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/create_qr_code/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/create_qr_code/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/klarna/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/klarna/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/nasa_apod/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/nasa_apod/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/outschool/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/outschool/ai-plugin.json +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/outschool/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/outschool/paths/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/outschool/paths/get_classes.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/outschool/paths/search_teachers.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/security_config.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/speak/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/speak/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/web_scraper/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/web_scraper/ai-plugin.json +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/web_scraper/openapi.yaml +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/web_scraper/paths/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_specs/web_scraper/paths/scraper.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/open_api_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/openbb_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/reddit_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/retrieval_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/slack_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/stripe_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/twitter_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/video_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/weather_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/toolkits/whatsapp_toolkit.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/types/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/types/openai_types.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/utils/__init__.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/utils/async_func.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/utils/commons.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/utils/constants.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/utils/response_format.py +0 -0
- {camel_ai-0.2.19 → camel_ai-0.2.20a1}/camel/utils/token_counting.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: camel-ai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.20a1
|
|
4
4
|
Summary: Communicative Agents for AI Society Study
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: communicative-ai,ai-societies,artificial-intelligence,deep-learning,multi-agent-systems,cooperative-ai,natural-language-processing,large-language-models
|
|
@@ -408,7 +408,8 @@ Practical guides and tutorials for implementing specific functionalities in CAME
|
|
|
408
408
|
| **[CoT Data Generation and SFT Qwen with Unsolth](https://docs.camel-ai.org/cookbooks/data_generation/cot_data_gen_sft_qwen_unsolth_upload_huggingface.html)** | Discover how to generate CoT data using CAMEL and SFT Qwen with Unsolth, and seamlessly upload your data and model to Huggingface. |
|
|
409
409
|
| **[Agentic Data Generation, Evaluation & Filtering with Reward Models](https://docs.camel-ai.org/cookbooks/data_generation/synthetic_dataevaluation&filter_with_reward_model.html)** | Discover methods for generating, evaluating, and filtering agentic data using reward models to enhance the quality and efficiency of your synthetic data pipelines. |
|
|
410
410
|
| **[Data Model Generation and Structured Output with Qwen Model](https://docs.camel-ai.org/cookbooks/data_generation/data_model_generation_and_structured_output_with_qwen.html)** |Learn how to generate data models and structured outputs using the Qwen Model for improved data representation.|
|
|
411
|
-
|
|
411
|
+
| **[Distill Math Reasoning Data from DeepSeek R1](https://docs.camel-ai.org/cookbooks/data_generation/distill_math_reasoning_data_from_deepseek_r1.html)** |Learn how to set up and leverage CAMEL's data distillation pipline for distilling high-quality maths reasoning data with thought process (Long CoT data)from deepseek R1, and uploading the results to Hugging Face.|
|
|
412
|
+
| **[Self-Improving Math Reasoning Data Distillation from DeepSeek R1](https://docs.camel-ai.org/cookbooks/data_generation/self_improving_math_reasoning_data_distillation_from_deepSeek_r1.html)** |Learn how to set up and leverage CAMEL's data distillation pipline for self-improving math reasoning data distillation from deepseek R1, and uploading the results to Hugging Face.|
|
|
412
413
|
|
|
413
414
|
### Multi-Agent Systems & Applications
|
|
414
415
|
| Cookbook | Description |
|
|
@@ -459,6 +460,8 @@ We implemented amazing research ideas from other works for you to build, compare
|
|
|
459
460
|
|
|
460
461
|
- `Source2Synth` from *Alisia Lupidi et al.*: [Source2Synth: Synthetic Data Generation and Curation Grounded in Real Data Sources](https://arxiv.org/abs/2409.08239). [[Example](https://github.com/camel-ai/camel/blob/master/examples/datagen/source2synth.py)]
|
|
461
462
|
|
|
463
|
+
- `STaR` from *Eric Zelikman et al.*: [STaR: Bootstrapping Reasoning With Reasoning](https://arxiv.org/abs/2203.14465). [[Example](https://github.com/camel-ai/camel/blob/master/examples/datagen/star)]
|
|
464
|
+
|
|
462
465
|
## Other Research Works Based on Camel
|
|
463
466
|
- [Agent Trust](http://agent-trust.camel-ai.org/): Can Large Language Model Agents Simulate Human Trust Behavior?
|
|
464
467
|
|
|
@@ -280,7 +280,8 @@ Practical guides and tutorials for implementing specific functionalities in CAME
|
|
|
280
280
|
| **[CoT Data Generation and SFT Qwen with Unsolth](https://docs.camel-ai.org/cookbooks/data_generation/cot_data_gen_sft_qwen_unsolth_upload_huggingface.html)** | Discover how to generate CoT data using CAMEL and SFT Qwen with Unsolth, and seamlessly upload your data and model to Huggingface. |
|
|
281
281
|
| **[Agentic Data Generation, Evaluation & Filtering with Reward Models](https://docs.camel-ai.org/cookbooks/data_generation/synthetic_dataevaluation&filter_with_reward_model.html)** | Discover methods for generating, evaluating, and filtering agentic data using reward models to enhance the quality and efficiency of your synthetic data pipelines. |
|
|
282
282
|
| **[Data Model Generation and Structured Output with Qwen Model](https://docs.camel-ai.org/cookbooks/data_generation/data_model_generation_and_structured_output_with_qwen.html)** |Learn how to generate data models and structured outputs using the Qwen Model for improved data representation.|
|
|
283
|
-
|
|
283
|
+
| **[Distill Math Reasoning Data from DeepSeek R1](https://docs.camel-ai.org/cookbooks/data_generation/distill_math_reasoning_data_from_deepseek_r1.html)** |Learn how to set up and leverage CAMEL's data distillation pipline for distilling high-quality maths reasoning data with thought process (Long CoT data)from deepseek R1, and uploading the results to Hugging Face.|
|
|
284
|
+
| **[Self-Improving Math Reasoning Data Distillation from DeepSeek R1](https://docs.camel-ai.org/cookbooks/data_generation/self_improving_math_reasoning_data_distillation_from_deepSeek_r1.html)** |Learn how to set up and leverage CAMEL's data distillation pipline for self-improving math reasoning data distillation from deepseek R1, and uploading the results to Hugging Face.|
|
|
284
285
|
|
|
285
286
|
### Multi-Agent Systems & Applications
|
|
286
287
|
| Cookbook | Description |
|
|
@@ -331,6 +332,8 @@ We implemented amazing research ideas from other works for you to build, compare
|
|
|
331
332
|
|
|
332
333
|
- `Source2Synth` from *Alisia Lupidi et al.*: [Source2Synth: Synthetic Data Generation and Curation Grounded in Real Data Sources](https://arxiv.org/abs/2409.08239). [[Example](https://github.com/camel-ai/camel/blob/master/examples/datagen/source2synth.py)]
|
|
333
334
|
|
|
335
|
+
- `STaR` from *Eric Zelikman et al.*: [STaR: Bootstrapping Reasoning With Reasoning](https://arxiv.org/abs/2203.14465). [[Example](https://github.com/camel-ai/camel/blob/master/examples/datagen/star)]
|
|
336
|
+
|
|
334
337
|
## Other Research Works Based on Camel
|
|
335
338
|
- [Agent Trust](http://agent-trust.camel-ai.org/): Can Large Language Model Agents Simulate Human Trust Behavior?
|
|
336
339
|
|
|
@@ -86,18 +86,18 @@ except (ImportError, AttributeError):
|
|
|
86
86
|
from camel.utils import track_agent
|
|
87
87
|
|
|
88
88
|
|
|
89
|
-
class
|
|
90
|
-
r"""Historical records of
|
|
89
|
+
class ToolCallingRecord(BaseModel):
|
|
90
|
+
r"""Historical records of tools called in the conversation.
|
|
91
91
|
|
|
92
92
|
Attributes:
|
|
93
|
-
|
|
93
|
+
tool_name (str): The name of the tool being called.
|
|
94
94
|
args (Dict[str, Any]): The dictionary of arguments passed to
|
|
95
|
-
the
|
|
96
|
-
result (Any): The execution result of calling this
|
|
95
|
+
the tools.
|
|
96
|
+
result (Any): The execution result of calling this tool.
|
|
97
97
|
tool_call_id (str): The ID of the tool call, if available.
|
|
98
98
|
"""
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
tool_name: str
|
|
101
101
|
args: Dict[str, Any]
|
|
102
102
|
result: Any
|
|
103
103
|
tool_call_id: str
|
|
@@ -106,10 +106,10 @@ class FunctionCallingRecord(BaseModel):
|
|
|
106
106
|
r"""Overridden version of the string function.
|
|
107
107
|
|
|
108
108
|
Returns:
|
|
109
|
-
str: Modified string to represent the
|
|
109
|
+
str: Modified string to represent the tool calling.
|
|
110
110
|
"""
|
|
111
111
|
return (
|
|
112
|
-
f"
|
|
112
|
+
f"Tool Execution: {self.tool_name}\n"
|
|
113
113
|
f"\tArgs: {self.args}\n"
|
|
114
114
|
f"\tResult: {self.result}\n"
|
|
115
115
|
)
|
|
@@ -489,7 +489,7 @@ class ChatAgent(BaseAgent):
|
|
|
489
489
|
usage: Optional[Dict[str, int]],
|
|
490
490
|
termination_reasons: List[str],
|
|
491
491
|
num_tokens: int,
|
|
492
|
-
tool_calls: List[
|
|
492
|
+
tool_calls: List[ToolCallingRecord],
|
|
493
493
|
external_tool_request: Optional[ChatCompletionMessageToolCall] = None,
|
|
494
494
|
) -> Dict[str, Any]:
|
|
495
495
|
r"""Returns a dictionary containing information about the chat session.
|
|
@@ -501,7 +501,7 @@ class ChatAgent(BaseAgent):
|
|
|
501
501
|
termination_reasons (List[str]): The reasons for the termination
|
|
502
502
|
of the chat session.
|
|
503
503
|
num_tokens (int): The number of tokens used in the chat session.
|
|
504
|
-
tool_calls (List[
|
|
504
|
+
tool_calls (List[ToolCallingRecord]): The list of function
|
|
505
505
|
calling records, containing the information of called tools.
|
|
506
506
|
external_tool_request
|
|
507
507
|
(Optional[ChatCompletionMessageToolCall], optional):
|
|
@@ -645,7 +645,7 @@ class ChatAgent(BaseAgent):
|
|
|
645
645
|
)
|
|
646
646
|
|
|
647
647
|
# Record function calls made during the session
|
|
648
|
-
tool_call_records: List[
|
|
648
|
+
tool_call_records: List[ToolCallingRecord] = []
|
|
649
649
|
|
|
650
650
|
external_tool_request = None
|
|
651
651
|
|
|
@@ -885,7 +885,7 @@ class ChatAgent(BaseAgent):
|
|
|
885
885
|
|
|
886
886
|
self.update_memory(input_message, OpenAIBackendRole.USER)
|
|
887
887
|
|
|
888
|
-
tool_call_records: List[
|
|
888
|
+
tool_call_records: List[ToolCallingRecord] = []
|
|
889
889
|
while True:
|
|
890
890
|
try:
|
|
891
891
|
openai_messages, num_tokens = self.memory.get_context()
|
|
@@ -970,7 +970,7 @@ class ChatAgent(BaseAgent):
|
|
|
970
970
|
|
|
971
971
|
def _step_tool_call_and_update(
|
|
972
972
|
self, response: ChatCompletion
|
|
973
|
-
) ->
|
|
973
|
+
) -> ToolCallingRecord:
|
|
974
974
|
r"""Processes a function call within the chat completion response,
|
|
975
975
|
records the function call in the provided list of tool calls and
|
|
976
976
|
updates the memory of the current agent.
|
|
@@ -980,7 +980,7 @@ class ChatAgent(BaseAgent):
|
|
|
980
980
|
completion.
|
|
981
981
|
|
|
982
982
|
Returns:
|
|
983
|
-
|
|
983
|
+
ToolCallingRecord: The record of calling the function.
|
|
984
984
|
"""
|
|
985
985
|
|
|
986
986
|
# Perform function calling
|
|
@@ -996,7 +996,7 @@ class ChatAgent(BaseAgent):
|
|
|
996
996
|
|
|
997
997
|
async def _step_tool_call_and_update_async(
|
|
998
998
|
self, response: ChatCompletion
|
|
999
|
-
) ->
|
|
999
|
+
) -> ToolCallingRecord:
|
|
1000
1000
|
(
|
|
1001
1001
|
func_assistant_msg,
|
|
1002
1002
|
func_result_msg,
|
|
@@ -1015,7 +1015,7 @@ class ChatAgent(BaseAgent):
|
|
|
1015
1015
|
List[str],
|
|
1016
1016
|
Dict[str, int],
|
|
1017
1017
|
str,
|
|
1018
|
-
|
|
1018
|
+
ToolCallingRecord,
|
|
1019
1019
|
int,
|
|
1020
1020
|
]:
|
|
1021
1021
|
r"""Internal function of structuring the output of the agent based on
|
|
@@ -1027,7 +1027,7 @@ class ChatAgent(BaseAgent):
|
|
|
1027
1027
|
|
|
1028
1028
|
Returns:
|
|
1029
1029
|
Tuple[List[BaseMessage], List[str], Dict[str, int], str,
|
|
1030
|
-
|
|
1030
|
+
ToolCallingRecord, int]:
|
|
1031
1031
|
A tuple containing the output messages, finish reasons, usage
|
|
1032
1032
|
dictionary, response ID, function calling record, and number of
|
|
1033
1033
|
tokens.
|
|
@@ -1141,7 +1141,7 @@ class ChatAgent(BaseAgent):
|
|
|
1141
1141
|
finish_reasons: List[str],
|
|
1142
1142
|
usage_dict: Dict[str, int],
|
|
1143
1143
|
response_id: str,
|
|
1144
|
-
tool_calls: List[
|
|
1144
|
+
tool_calls: List[ToolCallingRecord],
|
|
1145
1145
|
num_tokens: int,
|
|
1146
1146
|
external_tool_request: Optional[ChatCompletionMessageToolCall] = None,
|
|
1147
1147
|
) -> Dict[str, Any]:
|
|
@@ -1160,7 +1160,7 @@ class ChatAgent(BaseAgent):
|
|
|
1160
1160
|
usage_dict (Dict[str, int]): Dictionary containing token usage
|
|
1161
1161
|
information.
|
|
1162
1162
|
response_id (str): The ID of the response from the model.
|
|
1163
|
-
tool_calls (List[
|
|
1163
|
+
tool_calls (List[ToolCallingRecord]): Records of function calls
|
|
1164
1164
|
made during this step.
|
|
1165
1165
|
num_tokens (int): The number of tokens used in this step.
|
|
1166
1166
|
external_tool_request (Optional[ChatCompletionMessageToolCall]):
|
|
@@ -1335,7 +1335,7 @@ class ChatAgent(BaseAgent):
|
|
|
1335
1335
|
def _step_token_exceed(
|
|
1336
1336
|
self,
|
|
1337
1337
|
num_tokens: int,
|
|
1338
|
-
tool_calls: List[
|
|
1338
|
+
tool_calls: List[ToolCallingRecord],
|
|
1339
1339
|
termination_reason: str,
|
|
1340
1340
|
) -> ChatAgentResponse:
|
|
1341
1341
|
r"""Return trivial response containing number of tokens and information
|
|
@@ -1343,7 +1343,7 @@ class ChatAgent(BaseAgent):
|
|
|
1343
1343
|
|
|
1344
1344
|
Args:
|
|
1345
1345
|
num_tokens (int): Number of tokens in the messages.
|
|
1346
|
-
tool_calls (List[
|
|
1346
|
+
tool_calls (List[ToolCallingRecord]): List of information
|
|
1347
1347
|
objects of functions called in the current step.
|
|
1348
1348
|
termination_reason (str): String of termination reason.
|
|
1349
1349
|
|
|
@@ -1372,7 +1372,7 @@ class ChatAgent(BaseAgent):
|
|
|
1372
1372
|
self,
|
|
1373
1373
|
response: ChatCompletion,
|
|
1374
1374
|
) -> Tuple[
|
|
1375
|
-
FunctionCallingMessage, FunctionCallingMessage,
|
|
1375
|
+
FunctionCallingMessage, FunctionCallingMessage, ToolCallingRecord
|
|
1376
1376
|
]:
|
|
1377
1377
|
r"""Execute the function with arguments following the model's response.
|
|
1378
1378
|
|
|
@@ -1418,8 +1418,8 @@ class ChatAgent(BaseAgent):
|
|
|
1418
1418
|
)
|
|
1419
1419
|
|
|
1420
1420
|
# Record information about this function call
|
|
1421
|
-
func_record =
|
|
1422
|
-
|
|
1421
|
+
func_record = ToolCallingRecord(
|
|
1422
|
+
tool_name=func_name,
|
|
1423
1423
|
args=args,
|
|
1424
1424
|
result=result,
|
|
1425
1425
|
tool_call_id=tool_call_id,
|
|
@@ -1442,7 +1442,7 @@ class ChatAgent(BaseAgent):
|
|
|
1442
1442
|
self,
|
|
1443
1443
|
response: ChatCompletion,
|
|
1444
1444
|
) -> Tuple[
|
|
1445
|
-
FunctionCallingMessage, FunctionCallingMessage,
|
|
1445
|
+
FunctionCallingMessage, FunctionCallingMessage, ToolCallingRecord
|
|
1446
1446
|
]:
|
|
1447
1447
|
r"""Execute the async function with arguments following the model's
|
|
1448
1448
|
response.
|
|
@@ -1488,8 +1488,8 @@ class ChatAgent(BaseAgent):
|
|
|
1488
1488
|
)
|
|
1489
1489
|
|
|
1490
1490
|
# Record information about this function call
|
|
1491
|
-
func_record =
|
|
1492
|
-
|
|
1491
|
+
func_record = ToolCallingRecord(
|
|
1492
|
+
tool_name=func_name,
|
|
1493
1493
|
args=args,
|
|
1494
1494
|
result=result,
|
|
1495
1495
|
tool_call_id=tool_call_id,
|
|
@@ -20,6 +20,7 @@ from .groq_config import GROQ_API_PARAMS, GroqConfig
|
|
|
20
20
|
from .internlm_config import INTERNLM_API_PARAMS, InternLMConfig
|
|
21
21
|
from .litellm_config import LITELLM_API_PARAMS, LiteLLMConfig
|
|
22
22
|
from .mistral_config import MISTRAL_API_PARAMS, MistralConfig
|
|
23
|
+
from .moonshot_config import MOONSHOT_API_PARAMS, MoonshotConfig
|
|
23
24
|
from .nvidia_config import NVIDIA_API_PARAMS, NvidiaConfig
|
|
24
25
|
from .ollama_config import OLLAMA_API_PARAMS, OllamaConfig
|
|
25
26
|
from .openai_config import OPENAI_API_PARAMS, ChatGPTConfig
|
|
@@ -32,6 +33,7 @@ from .samba_config import (
|
|
|
32
33
|
SambaVerseAPIConfig,
|
|
33
34
|
)
|
|
34
35
|
from .sglang_config import SGLANG_API_PARAMS, SGLangConfig
|
|
36
|
+
from .siliconflow_config import SILICONFLOW_API_PARAMS, SiliconFlowConfig
|
|
35
37
|
from .togetherai_config import TOGETHERAI_API_PARAMS, TogetherAIConfig
|
|
36
38
|
from .vllm_config import VLLM_API_PARAMS, VLLMConfig
|
|
37
39
|
from .yi_config import YI_API_PARAMS, YiConfig
|
|
@@ -79,4 +81,8 @@ __all__ = [
|
|
|
79
81
|
'DEEPSEEK_API_PARAMS',
|
|
80
82
|
'InternLMConfig',
|
|
81
83
|
'INTERNLM_API_PARAMS',
|
|
84
|
+
'MoonshotConfig',
|
|
85
|
+
"MOONSHOT_API_PARAMS",
|
|
86
|
+
'SiliconFlowConfig',
|
|
87
|
+
'SILICONFLOW_API_PARAMS',
|
|
82
88
|
]
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
from typing import List, Optional, Union
|
|
16
|
+
|
|
17
|
+
from camel.configs.base_config import BaseConfig
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class MoonshotConfig(BaseConfig):
|
|
21
|
+
r"""Defines the parameters for generating chat completions using the
|
|
22
|
+
Moonshot API. You can refer to the following link for more details:
|
|
23
|
+
https://platform.moonshot.cn/docs/api-reference
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
temperature (float, optional): Controls randomness in the response.
|
|
27
|
+
Lower values make the output more focused and deterministic.
|
|
28
|
+
(default: :obj:`0.3`)
|
|
29
|
+
max_tokens (int, optional): The maximum number of tokens to generate.
|
|
30
|
+
(default: :obj:`None`)
|
|
31
|
+
stream (bool, optional): Whether to stream the response.
|
|
32
|
+
(default: :obj:`False`)
|
|
33
|
+
tools (list, optional): List of tools that the model can use for
|
|
34
|
+
function calling. Each tool should be a dictionary containing
|
|
35
|
+
type, function name, description, and parameters.
|
|
36
|
+
(default: :obj:`None`)
|
|
37
|
+
top_p (float, optional): Controls diversity via nucleus sampling.
|
|
38
|
+
(default: :obj:`1.0`)
|
|
39
|
+
n (int, optional): How many chat completion choices to generate for
|
|
40
|
+
each input message. (default: :obj:`1`)
|
|
41
|
+
presence_penalty (float, optional): Penalty for new tokens based on
|
|
42
|
+
whether they appear in the text so far.
|
|
43
|
+
(default: :obj:`0.0`)
|
|
44
|
+
frequency_penalty (float, optional): Penalty for new tokens based on
|
|
45
|
+
their frequency in the text so far.
|
|
46
|
+
(default: :obj:`0.0`)
|
|
47
|
+
stop (Optional[Union[str, List[str]]], optional): Up to 4 sequences
|
|
48
|
+
where the API will stop generating further tokens.
|
|
49
|
+
(default: :obj:`None`)
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
temperature: float = 0.3
|
|
53
|
+
max_tokens: Optional[int] = None
|
|
54
|
+
stream: bool = False
|
|
55
|
+
tools: Optional[list] = None
|
|
56
|
+
top_p: float = 1.0
|
|
57
|
+
n: int = 1
|
|
58
|
+
presence_penalty: float = 0.0
|
|
59
|
+
frequency_penalty: float = 0.0
|
|
60
|
+
stop: Optional[Union[str, List[str]]] = None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
MOONSHOT_API_PARAMS = {param for param in MoonshotConfig.model_fields.keys()}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Any, Sequence, Type, Union
|
|
17
|
+
|
|
18
|
+
from pydantic import BaseModel
|
|
19
|
+
|
|
20
|
+
from camel.configs.base_config import BaseConfig
|
|
21
|
+
from camel.types import NOT_GIVEN, NotGiven
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class SiliconFlowConfig(BaseConfig):
|
|
25
|
+
r"""Defines the parameters for generating chat completions using the
|
|
26
|
+
SiliconFlow API.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
temperature (float, optional): Determines the degree of randomness
|
|
30
|
+
in the response. (default: :obj:`0.7`)
|
|
31
|
+
top_p (float, optional): The top_p (nucleus) parameter is used to
|
|
32
|
+
dynamically adjust the number of choices for each predicted token
|
|
33
|
+
based on the cumulative probabilities. (default: :obj:`0.7`)
|
|
34
|
+
n (int, optional): Number of generations to return. (default::obj:`1`)
|
|
35
|
+
response_format (object, optional): An object specifying the format
|
|
36
|
+
that the model must output.
|
|
37
|
+
stream (bool, optional): If set, tokens are returned as Server-Sent
|
|
38
|
+
Events as they are made available. (default: :obj:`False`)
|
|
39
|
+
stop (str or list, optional): Up to :obj:`4` sequences where the API
|
|
40
|
+
will stop generating further tokens. (default: :obj:`None`)
|
|
41
|
+
max_tokens (int, optional): The maximum number of tokens to generate.
|
|
42
|
+
(default: :obj:`None`)
|
|
43
|
+
frequency_penalty (float, optional): Number between :obj:`-2.0` and
|
|
44
|
+
:obj:`2.0`. Positive values penalize new tokens based on their
|
|
45
|
+
existing frequency in the text so far, decreasing the model's
|
|
46
|
+
likelihood to repeat the same line verbatim. See more information
|
|
47
|
+
about frequency and presence penalties. (default: :obj:`0.0`)
|
|
48
|
+
tools (list[FunctionTool], optional): A list of tools the model may
|
|
49
|
+
call. Currently, only functions are supported as a tool. Use this
|
|
50
|
+
to provide a list of functions the model may generate JSON inputs
|
|
51
|
+
for. A max of 128 functions are supported.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
temperature: float = 0.7
|
|
55
|
+
top_p: float = 0.7
|
|
56
|
+
n: int = 1
|
|
57
|
+
stream: bool = False
|
|
58
|
+
stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
|
|
59
|
+
max_tokens: Union[int, NotGiven] = NOT_GIVEN
|
|
60
|
+
response_format: Union[Type[BaseModel], dict, NotGiven] = NOT_GIVEN
|
|
61
|
+
frequency_penalty: float = 0.0
|
|
62
|
+
|
|
63
|
+
def as_dict(self) -> dict[str, Any]:
|
|
64
|
+
r"""Convert the current configuration to a dictionary.
|
|
65
|
+
|
|
66
|
+
This method converts the current configuration object to a dictionary
|
|
67
|
+
representation, which can be used for serialization or other purposes.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
dict[str, Any]: A dictionary representation of the current
|
|
71
|
+
configuration.
|
|
72
|
+
"""
|
|
73
|
+
config_dict = self.model_dump()
|
|
74
|
+
if self.tools:
|
|
75
|
+
from camel.toolkits import FunctionTool
|
|
76
|
+
|
|
77
|
+
tools_schema = []
|
|
78
|
+
for tool in self.tools:
|
|
79
|
+
if not isinstance(tool, FunctionTool):
|
|
80
|
+
raise ValueError(
|
|
81
|
+
f"The tool {tool} should "
|
|
82
|
+
"be an instance of `FunctionTool`."
|
|
83
|
+
)
|
|
84
|
+
tools_schema.append(tool.get_openai_tool_schema())
|
|
85
|
+
config_dict["tools"] = NOT_GIVEN
|
|
86
|
+
return config_dict
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
SILICONFLOW_API_PARAMS = {
|
|
90
|
+
param for param in SiliconFlowConfig.model_fields.keys()
|
|
91
|
+
}
|
|
@@ -32,19 +32,19 @@ class HuggingFaceDatasetManager(BaseDatasetManager):
|
|
|
32
32
|
|
|
33
33
|
Args:
|
|
34
34
|
token (str): The Hugging Face API token. If not provided, the token
|
|
35
|
-
will be read from the environment variable `
|
|
35
|
+
will be read from the environment variable `HF_TOKEN`.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
38
|
@api_keys_required(
|
|
39
39
|
[
|
|
40
|
-
("token", "
|
|
40
|
+
("token", "HF_TOKEN"),
|
|
41
41
|
]
|
|
42
42
|
)
|
|
43
43
|
@dependencies_required('huggingface_hub')
|
|
44
44
|
def __init__(self, token: Optional[str] = None):
|
|
45
45
|
from huggingface_hub import HfApi
|
|
46
46
|
|
|
47
|
-
self._api_key = token or os.getenv("
|
|
47
|
+
self._api_key = token or os.getenv("HF_TOKEN")
|
|
48
48
|
self.api = HfApi(token=self._api_key)
|
|
49
49
|
|
|
50
50
|
def create_dataset_card(
|
|
@@ -35,6 +35,11 @@ class JinaEmbedding(BaseEmbedding[Union[str, Image.Image]]):
|
|
|
35
35
|
Jina AI. (default: :obj:`None`)
|
|
36
36
|
dimensions (Optional[int], optional): The dimension of the output
|
|
37
37
|
embeddings. (default: :obj:`None`)
|
|
38
|
+
embedding_type (Optional[str], optional): The type of embedding format
|
|
39
|
+
to generate. Options: 'int8' (binary encoding with higher storage
|
|
40
|
+
and transfer efficiency), 'uint8' (unsigned binary encoding with
|
|
41
|
+
higher storage and transfer efficiency), 'base64' (base64 string
|
|
42
|
+
encoding with higher transfer efficiency). (default: :obj:`None`)
|
|
38
43
|
task (Optional[str], optional): The type of task for text embeddings.
|
|
39
44
|
Options: retrieval.query, retrieval.passage, text-matching,
|
|
40
45
|
classification, separation. (default: :obj:`None`)
|
|
@@ -120,7 +125,7 @@ class JinaEmbedding(BaseEmbedding[Union[str, Image.Image]]):
|
|
|
120
125
|
else:
|
|
121
126
|
raise ValueError(
|
|
122
127
|
f"Input type {type(obj)} is not supported. "
|
|
123
|
-
"Must be either str or PIL.Image"
|
|
128
|
+
"Must be either str or PIL.Image."
|
|
124
129
|
)
|
|
125
130
|
|
|
126
131
|
data = {
|
|
@@ -24,6 +24,7 @@ from .litellm_model import LiteLLMModel
|
|
|
24
24
|
from .mistral_model import MistralModel
|
|
25
25
|
from .model_factory import ModelFactory
|
|
26
26
|
from .model_manager import ModelManager, ModelProcessingError
|
|
27
|
+
from .moonshot_model import MoonshotModel
|
|
27
28
|
from .nemotron_model import NemotronModel
|
|
28
29
|
from .nvidia_model import NvidiaModel
|
|
29
30
|
from .ollama_model import OllamaModel
|
|
@@ -70,4 +71,5 @@ __all__ = [
|
|
|
70
71
|
'DeepSeekModel',
|
|
71
72
|
'FishAudioModel',
|
|
72
73
|
'InternLMModel',
|
|
74
|
+
'MoonshotModel',
|
|
73
75
|
]
|
|
@@ -23,6 +23,7 @@ from camel.models.groq_model import GroqModel
|
|
|
23
23
|
from camel.models.internlm_model import InternLMModel
|
|
24
24
|
from camel.models.litellm_model import LiteLLMModel
|
|
25
25
|
from camel.models.mistral_model import MistralModel
|
|
26
|
+
from camel.models.moonshot_model import MoonshotModel
|
|
26
27
|
from camel.models.nvidia_model import NvidiaModel
|
|
27
28
|
from camel.models.ollama_model import OllamaModel
|
|
28
29
|
from camel.models.openai_compatible_model import OpenAICompatibleModel
|
|
@@ -31,6 +32,7 @@ from camel.models.qwen_model import QwenModel
|
|
|
31
32
|
from camel.models.reka_model import RekaModel
|
|
32
33
|
from camel.models.samba_model import SambaModel
|
|
33
34
|
from camel.models.sglang_model import SGLangModel
|
|
35
|
+
from camel.models.siliconflow_model import SiliconFlowModel
|
|
34
36
|
from camel.models.stub_model import StubModel
|
|
35
37
|
from camel.models.togetherai_model import TogetherAIModel
|
|
36
38
|
from camel.models.vllm_model import VLLMModel
|
|
@@ -100,6 +102,8 @@ class ModelFactory:
|
|
|
100
102
|
model_class = LiteLLMModel
|
|
101
103
|
elif model_platform.is_nvidia:
|
|
102
104
|
model_class = NvidiaModel
|
|
105
|
+
elif model_platform.is_siliconflow:
|
|
106
|
+
model_class = SiliconFlowModel
|
|
103
107
|
|
|
104
108
|
elif model_platform.is_openai and model_type.is_openai:
|
|
105
109
|
model_class = OpenAIModel
|
|
@@ -127,6 +131,8 @@ class ModelFactory:
|
|
|
127
131
|
model_class = DeepSeekModel
|
|
128
132
|
elif model_platform.is_internlm and model_type.is_internlm:
|
|
129
133
|
model_class = InternLMModel
|
|
134
|
+
elif model_platform.is_moonshot and model_type.is_moonshot:
|
|
135
|
+
model_class = MoonshotModel
|
|
130
136
|
elif model_type == ModelType.STUB:
|
|
131
137
|
model_class = StubModel
|
|
132
138
|
|
|
@@ -0,0 +1,138 @@
|
|
|
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 os
|
|
16
|
+
from typing import Any, Dict, List, Optional, Union
|
|
17
|
+
|
|
18
|
+
from openai import OpenAI, Stream
|
|
19
|
+
|
|
20
|
+
from camel.configs import MOONSHOT_API_PARAMS, MoonshotConfig
|
|
21
|
+
from camel.messages import OpenAIMessage
|
|
22
|
+
from camel.models import BaseModelBackend
|
|
23
|
+
from camel.types import (
|
|
24
|
+
ChatCompletion,
|
|
25
|
+
ChatCompletionChunk,
|
|
26
|
+
ModelType,
|
|
27
|
+
)
|
|
28
|
+
from camel.utils import (
|
|
29
|
+
BaseTokenCounter,
|
|
30
|
+
OpenAITokenCounter,
|
|
31
|
+
api_keys_required,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class MoonshotModel(BaseModelBackend):
|
|
36
|
+
r"""Moonshot API in a unified BaseModelBackend interface.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
model_type (Union[ModelType, str]): Model for which a backend is
|
|
40
|
+
created, one of Moonshot series.
|
|
41
|
+
model_config_dict (Optional[Dict[str, Any]], optional): A dictionary
|
|
42
|
+
that will be fed into :obj:`openai.ChatCompletion.create()`. If
|
|
43
|
+
:obj:`None`, :obj:`MoonshotConfig().as_dict()` will be used.
|
|
44
|
+
(default: :obj:`None`)
|
|
45
|
+
api_key (Optional[str], optional): The API key for authenticating with
|
|
46
|
+
the Moonshot service. (default: :obj:`None`)
|
|
47
|
+
url (Optional[str], optional): The url to the Moonshot service.
|
|
48
|
+
(default: :obj:`https://api.moonshot.cn/v1`)
|
|
49
|
+
token_counter (Optional[BaseTokenCounter], optional): Token counter to
|
|
50
|
+
use for the model. If not provided, :obj:`OpenAITokenCounter(
|
|
51
|
+
ModelType.GPT_4)` will be used.
|
|
52
|
+
(default: :obj:`None`)
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
@api_keys_required([("api_key", "MOONSHOT_API_KEY")])
|
|
56
|
+
def __init__(
|
|
57
|
+
self,
|
|
58
|
+
model_type: Union[ModelType, str],
|
|
59
|
+
model_config_dict: Optional[Dict[str, Any]] = None,
|
|
60
|
+
api_key: Optional[str] = None,
|
|
61
|
+
url: Optional[str] = None,
|
|
62
|
+
token_counter: Optional[BaseTokenCounter] = None,
|
|
63
|
+
) -> None:
|
|
64
|
+
if model_config_dict is None:
|
|
65
|
+
model_config_dict = MoonshotConfig().as_dict()
|
|
66
|
+
api_key = api_key or os.environ.get("MOONSHOT_API_KEY")
|
|
67
|
+
url = url or os.environ.get(
|
|
68
|
+
"MOONSHOT_API_BASE_URL",
|
|
69
|
+
"https://api.moonshot.cn/v1",
|
|
70
|
+
)
|
|
71
|
+
super().__init__(
|
|
72
|
+
model_type, model_config_dict, api_key, url, token_counter
|
|
73
|
+
)
|
|
74
|
+
self._client = OpenAI(
|
|
75
|
+
api_key=self._api_key,
|
|
76
|
+
timeout=180,
|
|
77
|
+
max_retries=3,
|
|
78
|
+
base_url=self._url,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def run(
|
|
82
|
+
self,
|
|
83
|
+
messages: List[OpenAIMessage],
|
|
84
|
+
) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]:
|
|
85
|
+
r"""Runs inference of Moonshot chat completion.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
messages (List[OpenAIMessage]): Message list with the chat history
|
|
89
|
+
in OpenAI API format.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Union[ChatCompletion, Stream[ChatCompletionChunk]]:
|
|
93
|
+
`ChatCompletion` in the non-stream mode, or
|
|
94
|
+
`Stream[ChatCompletionChunk]` in the stream mode.
|
|
95
|
+
"""
|
|
96
|
+
response = self._client.chat.completions.create(
|
|
97
|
+
messages=messages,
|
|
98
|
+
model=self.model_type,
|
|
99
|
+
**self.model_config_dict,
|
|
100
|
+
)
|
|
101
|
+
return response
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def token_counter(self) -> BaseTokenCounter:
|
|
105
|
+
r"""Initialize the token counter for the model backend.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
OpenAITokenCounter: The token counter following the model's
|
|
109
|
+
tokenization style.
|
|
110
|
+
"""
|
|
111
|
+
if not self._token_counter:
|
|
112
|
+
self._token_counter = OpenAITokenCounter(ModelType.GPT_4O_MINI)
|
|
113
|
+
return self._token_counter
|
|
114
|
+
|
|
115
|
+
def check_model_config(self):
|
|
116
|
+
r"""Check whether the model configuration contains any
|
|
117
|
+
unexpected arguments to Moonshot API.
|
|
118
|
+
|
|
119
|
+
Raises:
|
|
120
|
+
ValueError: If the model configuration dictionary contains any
|
|
121
|
+
unexpected arguments to Moonshot API.
|
|
122
|
+
"""
|
|
123
|
+
for param in self.model_config_dict:
|
|
124
|
+
if param not in MOONSHOT_API_PARAMS:
|
|
125
|
+
raise ValueError(
|
|
126
|
+
f"Unexpected argument `{param}` is "
|
|
127
|
+
"input into Moonshot model backend."
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def stream(self) -> bool:
|
|
132
|
+
r"""Returns whether the model is in stream mode, which sends partial
|
|
133
|
+
results each time.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
bool: Whether the model is in stream mode.
|
|
137
|
+
"""
|
|
138
|
+
return self.model_config_dict.get('stream', False)
|