Camel介绍

CAMEL 是一个开源社区,致力于探索代理的扩展规律。我们相信,在大规模研究这些代理可以提供对其行为、能力和潜在风险的宝贵见解。为了促进该领域的研究,我们实现了并支持各种类型的代理、任务、提示、模型和模拟环境。

CAMEL :找到智能体的扩展规律。第一个也是最好的多智能体框架。

CAMEL 框架设计原则

可演化性

该框架通过生成数据并与环境交互,使多智能体系统能够持续进化。这种进化可以由可验证奖励驱动的强化学习或监督学习驱动。

规模性

该框架旨在支持百万级代理的系统,确保在大规模情况下实现高效的协调、通信和资源管理。

有状态性

代理保持状态记忆,使它们能够进行多步与环境的交互,并高效地应对复杂的任务。

代码即提示

每一行代码和注释都作为代理的提示。代码应编写得清晰易读,确保人类和代理都能有效解读。

GitHub地址:https://github.com/camel-ai/camel。

Camel初探

我使用从源代码中使用 uv 这种方式进行安装。

git clone https://github.com/camel-ai/camel.git
cd camel

如果没安装uv需要安装。

pip install uv

创建一个虚拟环境。

uv venv .venv --python=3.10

激活虚拟环境。

.venv\Scripts\activate

安装CAMEL及其依赖。

uv pip install -e ".[all, dev, docs]"

开发者可以安装pre-commit hooks 与 mypy。

uv pip install pre-commit mypy
pre-commit install

现在先随便跑个例子看看。

我想要使用硅基流动的模型,就可以在.env文件中这样写:

Silicon_Model_ID="Qwen/Qwen2.5-72B-Instruct"
SiliconCloud_API_KEY="你的api_key"
SiliconCloud_Base_URL="https://api.siliconflow.cn/v1"

我跑的例子是这个:camel\examples\ai_society\role_playing_multi_lingual.py

将代码修改为如下的形式即可:

# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
from colorama import Fore from camel.societies import RolePlaying
from camel.utils import print_text_animated def main(model=None) -> None:
task_prompt = "Develop a trading bot for the stock market"
role_play_session = RolePlaying(
assistant_role_name="Python Programmer",
assistant_agent_kwargs=dict(model=model),
user_role_name="Stock Trader",
user_agent_kwargs=dict(model=model),
task_prompt=task_prompt,
with_task_specify=True,
task_specify_agent_kwargs=dict(model=model),
output_language="Chinese", # Arabic, French, Spanish, ...
) print(
Fore.GREEN
+ f"AI Assistant sys message:\n{role_play_session.assistant_sys_msg}\n"
)
print(
Fore.BLUE + f"AI User sys message:\n{role_play_session.user_sys_msg}\n"
) print(Fore.YELLOW + f"Original task prompt:\n{task_prompt}\n")
print(
Fore.CYAN
+ "Specified task prompt:"
+ f"\n{role_play_session.specified_task_prompt}\n"
)
print(Fore.RED + f"Final task prompt:\n{role_play_session.task_prompt}\n") chat_turn_limit, n = 50, 0
input_msg = role_play_session.init_chat()
while n < chat_turn_limit:
n += 1
assistant_response, user_response = role_play_session.step(input_msg) if assistant_response.terminated:
print(
Fore.GREEN
+ (
"AI Assistant terminated. Reason: "
f"{assistant_response.info['termination_reasons']}."
)
)
break
if user_response.terminated:
print(
Fore.GREEN
+ (
"AI User terminated. "
f"Reason: {user_response.info['termination_reasons']}."
)
)
break print_text_animated(
Fore.BLUE + f"AI User:\n\n{user_response.msg.content}\n"
)
print_text_animated(
Fore.GREEN + "AI Assistant:\n\n"
f"{assistant_response.msg.content}\n"
) if "CAMEL_TASK_DONE" in user_response.msg.content:
break input_msg = assistant_response.msg if __name__ == "__main__":
from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
import pathlib
import os
from dotenv import load_dotenv base_dir = pathlib.Path(__file__).parent.parent.parent
env_path = base_dir / ".env"
load_dotenv(dotenv_path=str(env_path)) modeltype = os.getenv("Silicon_Model_ID")
api_key = os.getenv("SiliconCloud_API_KEY")
base_url = os.getenv("SiliconCloud_Base_URL")
siliconcloud_model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
model_type=modeltype,
api_key=api_key,
url=base_url,
model_config_dict={"temperature": 0.4, "max_tokens": 4096},
)
main(siliconcloud_model)

运行效果:

算是把环境搭建好了。

现在就可以开始学习Camel这个多智能体框架了。

Camel多智能体框架初探的更多相关文章

  1. TensorFlow利用A3C算法训练智能体玩CartPole游戏

    本教程讲解如何使用深度强化学习训练一个可以在 CartPole 游戏中获胜的模型.研究人员使用 tf.keras.OpenAI 训练了一个使用「异步优势动作评价」(Asynchronous Advan ...

  2. 伯克利推出「看视频学动作」的AI智能体

    伯克利曾经提出 DeepMimic框架,让智能体模仿参考动作片段来学习高难度技能.但这些参考片段都是经过动作捕捉合成的高度结构化数据,数据本身的获取需要很高的成本.而近日,他们又更进一步,提出了可以直 ...

  3. DRL 教程 | 如何保持运动小车上的旗杆屹立不倒?TensorFlow利用A3C算法训练智能体玩CartPole游戏

    本教程讲解如何使用深度强化学习训练一个可以在 CartPole 游戏中获胜的模型.研究人员使用 tf.keras.OpenAI 训练了一个使用「异步优势动作评价」(Asynchronous Advan ...

  4. 多智能体系统(MAS)简介

    1.背景   自然界中大量个体聚集时往往能够形成协调.有序,甚至令人感到震撼的运动场景,比如天空中集体翱翔的庞大的鸟群.海洋中成群游动的鱼群,陆地上合作捕猎的狼群.这些群体现象所表现出的分布.协调.自 ...

  5. 【SerpentAI:Python开源游戏智能体开发框架——相比OpenAI Universe可导入自己的游戏、可脱离Docker/VNC运行】

    https://weibo.com/fly51fly?from=myfollow_all&is_all=1#1514439335614 [SerpentAI:Python开源游戏智能体开发框架 ...

  6. STM32W108无线传感器网络节点自组织与移动智能体导航技术

    使用STM32W108无线开发板及节点完毕大规模网络的自组建,网络模型选择树型,网络组建完毕之后,使用基于接收信号强度指示RSSI(ReceivedSignal Strength Indication ...

  7. 开发指南专题二:JEECG微云高速开发平台JEECG框架初探

    开发指南专题二:JEECG微云高速开发平台JEECG框架初探 2.JEECG框架初探 2.1演示系统 打开浏览器输入JEECG演示环境界址:http://demo.jeecg.org:8090/能够看 ...

  8. django框架初探

    django框架初探 1.web框架介绍 web框架本质是一个socket服务端.每一个端口只能被一个程序监听. web程序分为两个部分: 服务器程序:对socket服务器封装,解析http请求,发送 ...

  9. RNN及其变体框架

    RNN及其变体框架  含RNN推导 LSTM理解 理解LSTM网络  算法细节理解及参考文献  

  10. 基于ROBO-MAS多智能体自主协同 高频投影定位系统

随机推荐

  1. OpenWrt作为旁路由配置Wireguard 实现内网穿透

    0. 前言 因为最近一直在折腾软路由相关的系统及配置,也在家里整了一套k8s的环境,有一定需求需要在外面去连这套k8s的环境作为开发环境的补充,虽然可以通过外网端口暴露的方式访问,但是还是觉得不太方便 ...

  2. 高通MSM8909 Mutil-HAL Sensor 调试

    Mutil-HAL的介绍: Sensors Multi-HAL 是一个框架,允许传感器 HAL 与其他传感器 HAL 一起运行. Sensors Multi-HAL 动态加载作为动态库存储在供应商分区 ...

  3. 今天记录一下uniapp制作小程序时包过大的解决方法

    在开发小程序的时候,如果业务过于复杂就会使得包太大无法上线,在这我总结了几个解决包过大的方法,避免无法上线 1.静态图片使用线上地址,不要放到项目中,除了navBar的icon,因为那个只能使用本地资 ...

  4. 手把手带你使用Karpenter减少K8s集群资源浪费

    Kubernetes 集群的主要成本因素之一是数据平面上的计算层.将 Kubernetes 集群运行在 Amazon EC2 Spot 实例上是一种显著降低计算成本的有效方式.使用 Spot 实例可以 ...

  5. Solution Set -「NOIP Simu.」20221111

    \(\mathscr{A}\sim\) 遗忘十字路   Cover:「CF 1746D」Paths on the Tree.   Tag:「C.性质/结论」   最原始的思路自然是 DP. 令 \(f ...

  6. Solution -「NOI 2017」「洛谷 P3826」蔬菜

    \(\mathscr{Description}\)   Link.   原题意比较简洁了.注意一下卖出的菜也会变质,且让它们代替未卖出的菜变质是更优的. \(\mathscr{Solution}\) ...

  7. jdk8之stream原理及流创建、排序、转换等处理

    目录 一.为什么需要 Stream 二.什么是流 三.流的分类 1.有多种方式生成 Stream Source 2.流的操作类型 四.流的创建 1.数组和集合创建流 2.基本数值型流 3.数值流的构造 ...

  8. w3cschool-Apache Storm 教程

    https://www.w3cschool.cn/apache_storm/ Apache Storm教程Apache Storm简介Apache Storm核心概念Apache Storm集群架构A ...

  9. .NET Core GC计划阶段(plan_phase)底层原理浅谈

    简介 在mark_phase阶段之后,所有对象都被标记为有用/垃圾对象.此时,垃圾回收器已经拥有启动垃圾回收的所有前置准备工作. 这个时候,垃圾回收期应该执行"清除回收"还是&qu ...

  10. JS获取字符串长度的常用方法,汉字算两个字节

    JS获取字符串实际长度(双字节字符.汉字算两个字符) //第一种 GetLength = function(str) { var realLength = 0; for (var i = 0; i & ...