项目简介

AgentScope是一个创新的多智能体开发平台,旨在赋予开发人员使用大模型轻松构建多智能体应用的能力。
-
🤝 高易用:AgentScope专为开发人员设计,提供了丰富的组件, 全面的文档和广泛的兼容性。同时,AgentScope Workstation提供了在线拖拉拽编程和在线小助手(copilot)功能,帮助开发者迅速上手!
-
✅ 高鲁棒:支持自定义的容错控制和重试机制,以提高应用程序的稳定性。
-
🚀 分布式:支持以中心化的方式构建分布式多智能体应用程序。
支持的模型API
AgentScope提供了一系列ModelWrapper来支持本地模型服务和第三方模型API。
| API | Task | Model Wrapper | Configuration | Some Supported Models |
|---|---|---|---|---|
| OpenAI API | Chat | OpenAIChatWrapper |
guidance template |
gpt-4o, gpt-4, gpt-3.5-turbo, … |
| Embedding | OpenAIEmbeddingWrapper |
guidance template |
text-embedding-ada-002, … | |
| DALL·E | OpenAIDALLEWrapper |
guidance template |
dall-e-2, dall-e-3 | |
| DashScope API | Chat | DashScopeChatWrapper |
guidance template |
qwen-plus, qwen-max, … |
| Image Synthesis | DashScopeImageSynthesisWrapper |
guidance template |
wanx-v1 | |
| Text Embedding | DashScopeTextEmbeddingWrapper |
guidance template |
text-embedding-v1, text-embedding-v2, … | |
| Multimodal | DashScopeMultiModalWrapper |
guidance template |
qwen-vl-max, qwen-vl-chat-v1, qwen-audio-chat | |
| Gemini API | Chat | GeminiChatWrapper |
guidance template |
gemini-pro, … |
| Embedding | GeminiEmbeddingWrapper |
guidance template |
models/embedding-001, … | |
| ZhipuAI API | Chat | ZhipuAIChatWrapper |
guidance template |
glm-4, … |
| Embedding | ZhipuAIEmbeddingWrapper |
guidance template |
embedding-2, … | |
| ollama | Chat | OllamaChatWrapper |
guidance template |
llama3, llama2, Mistral, … |
| Embedding | OllamaEmbeddingWrapper |
guidance template |
llama2, Mistral, … | |
| Generation | OllamaGenerationWrapper |
guidance template |
llama2, Mistral, … | |
| LiteLLM API | Chat | LiteLLMChatWrapper |
guidance template |
models supported by litellm… |
| Yi API | Chat | YiChatWrapper |
guidance template |
yi-large, yi-medium, … |
| Post Request based API | – | PostAPIModelWrapper |
guidance template |
– |
支持的本地模型部署
AgentScope支持使用以下库快速部署本地模型服务。
-
ollama (CPU inference)
-
Flask + Transformers
-
Flask + ModelScope
-
FastChat
-
vllm
支持的服务
-
网络搜索
-
数据查询
-
数据检索
-
代码执行
-
文件操作
-
文本处理
-
多模态生成
-
维基百科搜索
-
TripAdvisor搜索
-
浏览器控制
样例应用
-
模型
-
在AgentScope中使用Llama3
-
对话
-
基础对话
-
带有@功能的自主对话
-
智能体自组织的对话
-
兼容LangChain的基础对话
-
与ReAct智能体对话
-
通过对话查询SQL信息
-
与RAG智能体对话
-
与gpt-4o模型对话
-
自定义工具函数
-
与SoftWare Engineering智能体对话
-
Mixture of Agents算法 -
流式对话 -
与CodeAct智能体对话 -
与Router Agent对话 -
游戏
-
五子棋
-
狼人杀
-
分布式
-
分布式对话
-
分布式辩论
-
分布式并行优化
-
分布式大规模仿真
更多模型API、服务和示例即将推出!
安装
AgentScope需要Python 3.9或更高版本。
注意:该项目目前正在积极开发中,建议从源码安装AgentScope。
从源码安装
-
以编辑模式安装AgentScope:
# 从github拉取源代码git clone https://github.com/modelscope/agentscope.git# 以编辑模式安装包cd agentscopepip install -e .
使用pip
-
从pip安装的AgentScope
pip install agentscope
额外依赖
为了支持不同的部署场景,AgentScope提供了若干个可选的依赖项。完整的可选依赖项列表请参考tutorial 以分布式模式为例,可以使用以下命令安装AgentScope:
On Windows
# From sourcepip install -e .[distribute]# From pypipip install agentscope[distribute]
On Mac & Linux
# From sourcepip install -e .\[distribute\]# From pypipip install agentscope\[distribute\]
快速开始
配置
AgentScope中,模型的部署和调用是通过ModelWrapper实现解耦的。
为了使用这些ModelWrapper, 您需要准备如下的模型配置文件:
model_config = {# 模型配置的名称,以及使用的模型wrapper"config_name": "{your_config_name}", # 模型配置的名称"model_type": "{model_type}", # 模型wrapper的类型# 用以初始化模型wrapper的详细参数# ...}
以OpenAI Chat API为例,模型配置如下:
openai_model_config = {"config_name": "my_openai_config", # 模型配置的名称"model_type": "openai_chat", # 模型wrapper的类型# 用以初始化模型wrapper的详细参数"model_name": "gpt-4", # OpenAI API中的模型名"api_key": "xxx", # OpenAI API的API密钥。如果未设置,将使用环境变量OPENAI_API_KEY。"organization": "xxx", # OpenAI API的组织。如果未设置,将使用环境变量OPENAI_ORGANIZATION。}
关于部署本地模型服务和准备模型配置的更多细节,请参阅我们的教程。
创建Agent
创建AgentScope内置的DialogAgent和UserAgent对象.
from agentscope.agents import DialogAgent, UserAgentimport agentscope# 加载模型配置agentscope.init(model_configs="./model_configs.json")# 创建对话Agent和用户Agentdialog_agent = DialogAgent(name="assistant",model_config_name="my_openai_config")user_agent = UserAgent()
构造对话
在AgentScope中,Message是Agent之间的桥梁,它是一个python字典(dict),包含两个必要字段name和content,以及一个可选字段url用于本地文件(图片、视频或音频)或网络链接。
from agentscope.message import Msgx = Msg(name="Alice", content="Hi!")x = Msg("Bob", "What about this picture I took?", url="/path/to/picture.jpg")
使用以下代码开始两个Agent(dialog_agent和user_agent)之间的对话:
x = Nonewhile True:x = dialog_agent(x)x = user_agent(x)if x.content == "exit": # 用户输入"exit"退出对话break
AgentScope前端
AgentScope 提供了一个易于使用的运行时用户界面,能够在前端显示多模态输出,包括文本、图像、音频和视频。
参考我们的教程了解更多细节。
项目链接
https://github.com/modelscope/agentscope/blob/main/README_ZH.md
扫码加入技术交流群,备注「开发语言-城市-昵称」
(文:GitHubStore)
