CAMEL一个提供各种类型的AI Agent代理、任务、提示、模型和模拟环境的AI 框架
CAMEL是一个开源AI多智能体研究社区,致力于探索大规模智能体系统的行为规律和扩展法则。该项目提供多样化的代理类型、任务环境和评估基准,支持动态通信、状态记忆等功能,可模拟多达100万个智能体的复杂交互。通过PyPI简单安装后,开发者可利用OpenAI兼容模型快速构建ChatAgent,并集成DuckDuckGo等工具实现搜索功能。实验表明,智能体的表现既取决于底层模型的推理能力,也与其是否支持
官网:github.com
CAMEL is an open-source community dedicated to finding the scaling laws of agents. We believe that studying these agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks. To facilitate research in this field, we implement and support various types of agents, tasks, prompts, models, and simulated environments.
CAMEL 是一个开源社区,致力于寻找AI Agent代理的扩展规律。我们相信,大规模研究这些AI Agent代理可以为了解它们的行为、能力和潜在风险提供有价值的见解。为了促进该领域的研究,我们实施并支持各种类型的AI Agent代理、任务、提示、模型和模拟环境。
为什么使用 CAMEL 进行研究?
我们是一个社区驱动的研究团队,由 100 多名研究人员组成,致力于推进多智能体系统的前沿研究。世界各地的研究人员选择 CAMEL 进行研究的原因如下。
✅ | 大规模代理系统 | 模拟多达 1M 个智能体,以研究复杂、多智能体环境中的紧急行为和缩放定律。 |
✅ | 动态通信 | 支持座席之间的实时交互,促进无缝协作以处理复杂的任务。 |
✅ | 状态内存 | 使座席能够保留和利用历史背景,从而改善对扩展交互的决策。 |
✅ | 支持多个基准测试 | 利用标准化基准严格评估代理性能,确保可重复性和可靠的比较。 |
✅ | 支持不同的代理类型 | 使用各种代理角色、任务、模型和环境,支持跨学科实验和各种研究应用程序。 |
✅ | 数据生成和工具集成 | 自动创建大规模结构化数据集,同时与多个工具无缝集成,从而简化合成数据生成和研究工作流程。 |
快速开始
由于 CAMEL 在 PyPI 上的可用性,因此安装 CAMEL 变得轻而易举。只需打开您的终端并运行:
pip install camel-ai
从 ChatAgent 开始
此示例演示如何使用 CAMEL 框架创建一个ChatAgent
并使用 DuckDuckGo 执行搜索查询。
安装工具包:
pip install 'camel-ai[web_tools]'
设置您的 OpenAI API 密钥:
export OPENAI_API_KEY='your_openai_api_key'
export OPENAI_BASE_URL='http://127.0.0.1:1337/v1'
根据项目里的代码,使用不同的环境变量
export OPENAI_COMPATIBILITY_API_KEY='your_openai_api_key'
export OPENAI_COMPATIBILITY_API_BASE_URL='http://127.0.0.1:1337/v1'
大模型api调用这里使用了本地自建的服务器,建立方法是pip安装g4f:
pip install g4f[all] -U
启动自建服务器g4f
g4f api
这样就可以使用http://127.0.0.1:1337/v1这个服务器了。
运行
将下面的代码存为cameldemo.py文件
from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
from camel.agents import ChatAgent
from camel.toolkits import SearchToolkit
import os
#model = ModelFactory.create(
#model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
# model_type=ModelType.GPT_4O,
#model_type="default",
#model_config_dict={"temperature": 0.0},
#)
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
#model_type="gpt-4o",
model_type="default",
api_key=os.environ.get("OPENAI_COMPATIBILITY_API_KEY"),
url=os.environ.get("OPENAI_COMPATIBILITY_API_BASE_URL"),
model_config_dict={"temperature": 0.4, "max_tokens": 4096},
)
search_tool = SearchToolkit().search_duckduckgo
#agent = ChatAgent(model=model, tools=[search_tool])
agent = ChatAgent(model=model, )
response_1 = agent.step("What is CAMEL-AI?")
print(response_1.msgs[0].content)
# CAMEL-AI is the first LLM (Large Language Model) multi-agent framework
# and an open-source community focused on finding the scaling laws of agents.
# ...
response_2 = agent.step("What is the Github link to CAMEL framework?")
print(response_2.msgs[0].content)
# The GitHub link to the CAMEL framework is
# [https://github.com/camel-ai/camel](https://github.com/camel-ai/camel).
运行测试代码
python cameldemo.py
输出:
CAMEL-AI stands for **Causality-Aware Multi-Entity Learning in Artificial Intelligence**. It represents a framework that harnesses the principles of causality to enhance the learning and inference processes of AI systems, especially when dealing with multiple interconnected entities or variables. Here are some key aspects:
### Key Features
1. **Causality Focus**:
- CAMEL-AI emphasizes understanding causal relationships between entities, which allows for more informed decision-making and predictions.
2. **Multi-Entity Learning**:
- The framework is designed to handle scenarios involving multiple entities, making it suitable for complex applications like social network analysis, economic modeling, and more.
3. **Enhanced Inference**:
- By incorporating causal reasoning, CAMEL-AI can draw better inferences from available data, leading to improved performance over traditional statistical methods.
4. **Real-World Applications**:
- The principles behind CAMEL-AI can be applied across various domains, including healthcare, finance, and personalized recommendation systems.
### Benefits
- **Better Interpretability**: Understanding causality can lead to more interpretable models.
- **Robustness**: Causal frameworks can provide robustness against changes in data distributions, leading to greater reliability in predictions.
- **Improved Generalization**: By learning the causal relations, models can generalize better to unseen situations.
### Conclusion
CAMEL-AI represents an important step towards more intelligent AI systems that not only learn from data but also understand the underlying relationships and causal mechanisms at play. This kind of approach is increasingly seen as crucial for developing AI that can operate effectively in real-world environments.
手动分割线===================================================
INFO: 127.0.0.1:62476 - "POST /v1/chat/completions HTTP/1.1" 200 OK
===================================================
I couldn't find information about the CAMEL framework's GitHub repository in the documentation. The search results primarily contain information about documentation tools and GitHub integration, but don't include details about the CAMEL AI framework's GitHub link.I wasn't able to find information about the CAMEL framework's GitHub repository in the available documentation. For questions about specific AI frameworks or GitHub repositories that aren't covered in the docs, you can contact support@mintlify.com for further assistance.
response_1 = agent.step("What is CAMEL-AI?")
response_2 = agent.step("What is the Github link to CAMEL framework?")
因为去掉了上网搜索功能,所以第二个问题它没有找到。后来再用文心模型测试,发现它是可以找到的,所以它受两个条件影响:如果模型足够强大,它自己不用搜索就能输出信息。如果模型支持functional,那么它可以调用function来拿到信息,比如网址信息。
本事实验之所以去掉上网搜索功能,是因为我的自建服务器的default模型是随机的,不能保证每次都调用使用带function call的模型。
调试
运行测试时报错openai.InternalServerError: Error code: 500
File "/home/skywalk/minipy312/lib/python3.12/site-packages/openai/_base_client.py", line 1047, in request
raise self._make_status_error_from_response(err.response) from None
openai.InternalServerError: Error code: 500 - {'error': {'message': 'ResponseError: Error 400: 400 Bad Request'}, 'model': 'default'}
升级openai代码
pip install openai -U
最后修改了代码如下:
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
#model_type="gpt-4o",
model_type="default",
api_key=os.environ.get("OPENAI_COMPATIBILITY_API_KEY"),
url=os.environ.get("OPENAI_COMPATIBILITY_API_BASE_URL"),
model_config_dict={"temperature": 0.4, "max_tokens": 4096},
)
去掉tools应用
#agent = ChatAgent(model=model, tools=[search_tool])
agent = ChatAgent(model=model, )
最终的结论:
如果用的模型不支持functional ,那么就要去掉tools应用。
更多推荐
所有评论(0)