Skip to content

armgit / camel

Public Imported from GitHub
0

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

feat: Support default model and platform setting from env (#1183)

Wendong-Fana9963e2adb40
diff --git a/README.md b/README.md
index d6edcdbea..f767cb112 100644
--- a/README.md
+++ b/README.md
@@ -160,62 +160,23 @@ pip install -e .[all] # (Optional)
Detailed guidance can be find [here](https://github.com/camel-ai/camel/blob/master/.container/README.md)
-## Documentation
-
-The [complete documentation](https://camel-ai.github.io/camel/) pages for the CAMEL package. Also, detailed tutorials for each part are provided below:
-
-### Agents
-Explore different types of agents, their roles, and their applications.
-
-- **[Creating Your First Agent](https://docs.camel-ai.org/cookbooks/create_your_first_agent.html)**
-- **[Creating Your First Agent Society](https://docs.camel-ai.org/cookbooks/create_your_first_agents_society.html)**
-- **[Embodied Agents](https://docs.camel-ai.org/cookbooks/embodied_agents.html)**
-- **[Critic Agents](https://docs.camel-ai.org/cookbooks/critic_agents_and_tree_search.html)**
-
----
+## Quick Start
-### Key Modules
-Core components and utilities to build, operate, and enhance CAMEL-AI agents and societies.
+By default, the agent uses the `ModelType.DEFAULT` model from the `ModelPlatformType.DEFAULT`. You can configure the default model platform and model type using environment variables. If these are not set, the agent will fall back to the default settings:
-| Module | Description |
-|:---|:---|
-| **[Models](https://docs.camel-ai.org/key_modules/models.html)** | Model architectures and customization options for agent intelligence. |
-| **[Messages](https://docs.camel-ai.org/key_modules/messages.html)** | Messaging protocols for agent communication. |
-| **[Memory](https://docs.camel-ai.org/key_modules/memory.html)** | Memory storage and retrieval mechanisms. |
-| **[Tools](https://docs.camel-ai.org/key_modules/tools.html)** | Tools integration for specialized agent tasks. |
-| **[Prompts](https://docs.camel-ai.org/key_modules/prompts.html)** | Prompt engineering and customization. |
-| **[Tasks](https://docs.camel-ai.org/key_modules/tasks.html)** | Task creation and management for agent workflows. |
-| **[Loaders](https://docs.camel-ai.org/key_modules/loaders.html)** | Data loading tools for agent operation. |
-| **[Storages](https://docs.camel-ai.org/key_modules/storages.html)** | Storage solutions for agent. |
-| **[Society](https://docs.camel-ai.org/key_modules/society.html)** | Components for building agent societies and inter-agent collaboration. |
-| **[Embeddings](https://docs.camel-ai.org/key_modules/embeddings.html)** | Embedding models for RAG. |
-| **[Retrievers](https://docs.camel-ai.org/key_modules/retrievers.html)** | Retrieval methods for knowledge access. |
----
+- `ModelPlatformType.DEFAULT = "openai"`
-### Cookbooks
-Practical guides and tutorials for implementing specific functionalities in CAMEL-AI agents and societies.
+- `ModelType.DEFAULT = "gpt-4o-mini"`
-| Cookbook | Description |
-|:---|:---|
-| **[Creating Your First Agent](https://docs.camel-ai.org/cookbooks/create_your_first_agent.html)** | A step-by-step guide to building your first agent. |
-| **[Creating Your First Agent Society](https://docs.camel-ai.org/cookbooks/create_your_first_agents_society.html)** | Learn to build a collaborative society of agents. |
-| **[Society Cookbook](https://docs.camel-ai.org/cookbooks/agents_society.html)** | Advanced configurations for agent societies. |
-| **[Model Speed Comparison Cookbook](https://docs.camel-ai.org/cookbooks/model_speed_comparison.html)** | Benchmarking models for performance. |
-| **[Message Cookbook](https://docs.camel-ai.org/cookbooks/agents_message.html)** | Best practices for message handling in agents. |
-| **[Tools Cookbook](https://docs.camel-ai.org/cookbooks/agents_with_tools.html)** | Integrating tools for enhanced functionality. |
-| **[Memory Cookbook](https://docs.camel-ai.org/cookbooks/agents_with_memory.html)** | Implementing memory systems in agents. |
-| **[RAG Cookbook](https://docs.camel-ai.org/cookbooks/agents_with_rag.html)** | Recipes for Retrieval-Augmented Generation. |
-| **[Prompting Cookbook](https://docs.camel-ai.org/cookbooks/agents_prompting.html)** | Techniques for effective prompt creation. |
-| **[Task Generation Cookbook](https://docs.camel-ai.org/cookbooks/task_generation.html)** | Automating task generation for agents. |
-| **[Graph RAG Cookbook](https://docs.camel-ai.org/cookbooks/knowledge_graph.html)** | Leveraging knowledge graphs with RAG. |
-| **[Role-Playing Scraper for Report & Knowledge Graph Generation](https://docs.camel-ai.org/cookbooks/roleplaying_scraper.html)** | Create role-playing agents for data scraping and reporting. |
-| **[Video Analysis](https://docs.camel-ai.org/cookbooks/video_analysis.html)** | Techniques for agents in video data analysis. |
-| **[Track CAMEL Agents with AgentOps](https://docs.camel-ai.org/cookbooks/agents_tracking.html)** | Tools for tracking and managing agents in operations. |
-| **[Create A Hackathon Judge Committee with Workforce](https://docs.camel-ai.org/cookbooks/workforce_judge_committee.html)** | Building a team of agents for collaborative judging. |
+### Setting Default Model Platform and Model Type (Optional)
-## Examples
+You can customize the default model platform and model type by setting the following environment variables:
+```bash
+export DEFAULT_MODEL_PLATFORM_TYPE=<your preferred platform> # e.g., openai, anthropic, etc.
+export DEFAULT_MODEL_TYPE=<your preferred model> # e.g., gpt-3.5-turbo, gpt-4o-mini, etc.
+```
-First, you need to add your OpenAI API key to system environment variables. The method to do this depends on your operating system and the shell you're using.
+### Setting Your Model API Key (Using OpenAI as an Example)
**For Bash shell (Linux, macOS, Git Bash on Windows):**
@@ -275,6 +236,59 @@ python examples/vision/image_crafting.py
```
For additional feature examples, see the [`examples`](https://github.com/camel-ai/camel/tree/master/examples) directory.
+## Documentation
+
+The [complete documentation](https://camel-ai.github.io/camel/) pages for the CAMEL package. Also, detailed tutorials for each part are provided below:
+
+### Agents
+Explore different types of agents, their roles, and their applications.
+
+- **[Creating Your First Agent](https://docs.camel-ai.org/cookbooks/create_your_first_agent.html)**
+- **[Creating Your First Agent Society](https://docs.camel-ai.org/cookbooks/create_your_first_agents_society.html)**
+- **[Embodied Agents](https://docs.camel-ai.org/cookbooks/embodied_agents.html)**
+- **[Critic Agents](https://docs.camel-ai.org/cookbooks/critic_agents_and_tree_search.html)**
+
+---
+
+### Key Modules
+Core components and utilities to build, operate, and enhance CAMEL-AI agents and societies.
+
+| Module | Description |
+|:---|:---|
+| **[Models](https://docs.camel-ai.org/key_modules/models.html)** | Model architectures and customization options for agent intelligence. |
+| **[Messages](https://docs.camel-ai.org/key_modules/messages.html)** | Messaging protocols for agent communication. |
+| **[Memory](https://docs.camel-ai.org/key_modules/memory.html)** | Memory storage and retrieval mechanisms. |
+| **[Tools](https://docs.camel-ai.org/key_modules/tools.html)** | Tools integration for specialized agent tasks. |
+| **[Prompts](https://docs.camel-ai.org/key_modules/prompts.html)** | Prompt engineering and customization. |
+| **[Tasks](https://docs.camel-ai.org/key_modules/tasks.html)** | Task creation and management for agent workflows. |
+| **[Loaders](https://docs.camel-ai.org/key_modules/loaders.html)** | Data loading tools for agent operation. |
+| **[Storages](https://docs.camel-ai.org/key_modules/storages.html)** | Storage solutions for agent. |
+| **[Society](https://docs.camel-ai.org/key_modules/society.html)** | Components for building agent societies and inter-agent collaboration. |
+| **[Embeddings](https://docs.camel-ai.org/key_modules/embeddings.html)** | Embedding models for RAG. |
+| **[Retrievers](https://docs.camel-ai.org/key_modules/retrievers.html)** | Retrieval methods for knowledge access. |
+---
+
+### Cookbooks
+Practical guides and tutorials for implementing specific functionalities in CAMEL-AI agents and societies.
+
+| Cookbook | Description |
+|:---|:---|
+| **[Creating Your First Agent](https://docs.camel-ai.org/cookbooks/create_your_first_agent.html)** | A step-by-step guide to building your first agent. |
+| **[Creating Your First Agent Society](https://docs.camel-ai.org/cookbooks/create_your_first_agents_society.html)** | Learn to build a collaborative society of agents. |
+| **[Society Cookbook](https://docs.camel-ai.org/cookbooks/agents_society.html)** | Advanced configurations for agent societies. |
+| **[Model Speed Comparison Cookbook](https://docs.camel-ai.org/cookbooks/model_speed_comparison.html)** | Benchmarking models for performance. |
+| **[Message Cookbook](https://docs.camel-ai.org/cookbooks/agents_message.html)** | Best practices for message handling in agents. |
+| **[Tools Cookbook](https://docs.camel-ai.org/cookbooks/agents_with_tools.html)** | Integrating tools for enhanced functionality. |
+| **[Memory Cookbook](https://docs.camel-ai.org/cookbooks/agents_with_memory.html)** | Implementing memory systems in agents. |
+| **[RAG Cookbook](https://docs.camel-ai.org/cookbooks/agents_with_rag.html)** | Recipes for Retrieval-Augmented Generation. |
+| **[Prompting Cookbook](https://docs.camel-ai.org/cookbooks/agents_prompting.html)** | Techniques for effective prompt creation. |
+| **[Task Generation Cookbook](https://docs.camel-ai.org/cookbooks/task_generation.html)** | Automating task generation for agents. |
+| **[Graph RAG Cookbook](https://docs.camel-ai.org/cookbooks/knowledge_graph.html)** | Leveraging knowledge graphs with RAG. |
+| **[Role-Playing Scraper for Report & Knowledge Graph Generation](https://docs.camel-ai.org/cookbooks/roleplaying_scraper.html)** | Create role-playing agents for data scraping and reporting. |
+| **[Video Analysis](https://docs.camel-ai.org/cookbooks/video_analysis.html)** | Techniques for agents in video data analysis. |
+| **[Track CAMEL Agents with AgentOps](https://docs.camel-ai.org/cookbooks/agents_tracking.html)** | Tools for tracking and managing agents in operations. |
+| **[Create A Hackathon Judge Committee with Workforce](https://docs.camel-ai.org/cookbooks/workforce_judge_committee.html)** | Building a team of agents for collaborative judging. |
+
## Utilize Various LLMs as Backends
For more details, please see our [`Models Documentation`](https://docs.camel-ai.org/key_modules/models.html#).
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index a9efebb80..125466923 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -122,8 +122,8 @@ class ChatAgent(BaseAgent):
system_message (Union[BaseMessage, str], optional): The system message
for the chat agent.
model (BaseModelBackend, optional): The model backend to use for
- generating responses. (default: :obj:`OpenAIModel` with
- `GPT_4O_MINI`)
+ generating responses. (default: :obj:`ModelPlatformType.DEFAULT`
+ with `ModelType.DEFAULT`)
memory (AgentMemory, optional): The agent memory for managing chat
messages. If `None`, a :obj:`ChatHistoryMemory` will be used.
(default: :obj:`None`)
diff --git a/camel/types/enums.py b/camel/types/enums.py
index 57d0702f1..adcf3bc9a 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -11,6 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
+import os
from enum import Enum, EnumMeta
from typing import cast
@@ -26,7 +27,7 @@ class RoleType(Enum):
class ModelType(UnifiedModelType, Enum):
- DEFAULT = "gpt-4o-mini"
+ DEFAULT = os.getenv("DEFAULT_MODEL_TYPE", "gpt-4o-mini")
GPT_3_5_TURBO = "gpt-3.5-turbo"
GPT_4 = "gpt-4"
@@ -517,7 +518,7 @@ class OpenAPIName(Enum):
class ModelPlatformType(Enum):
- DEFAULT = "openai"
+ DEFAULT = os.getenv("DEFAULT_MODEL_PLATFORM_TYPE", "openai")
OPENAI = "openai"
AZURE = "azure"
diff --git a/examples/toolkits/notion_toolkit.py b/examples/toolkits/notion_toolkit.py
index a84af1f97..94426a488 100644
--- a/examples/toolkits/notion_toolkit.py
+++ b/examples/toolkits/notion_toolkit.py
@@ -31,8 +31,8 @@ model_config_dict = ChatGPTConfig(
).as_dict()
model = ModelFactory.create(
- model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_4O_MINI,
+ model_platform=ModelPlatformType.DEFAULT,
+ model_type=ModelType.DEFAULT,
model_config_dict=model_config_dict,
)