分享
AgentScope 初探
输入“/”快速插入内容
🔍
AgentScope 初探
6257
8658
6
0
60%
40%
✅
本文档由
飞书用户5531
、
飞书用户9797
写作,感谢优秀的学习者为我们分享经验~
环境配置
安装AgentScope
详见
官方文档
•
源码安装
源码安装可以体验较新的功能(比如:适配
通义api
)
代码块
Python
# 从GitHub上拉取AgentScope的源代码
git clone https://github.com/modelscope/agentscope.git
cd AgentScope
# 针对本地化的multi-agent应用
pip install -e .
•
pip安装
注意:这个方法确实会很方便,
但建议用git下载源码,通过源码安装最新版agentscope
代码块
Bash
# 针对本地化的multi-agent应用
pip install agentscope
配置model_config
model_config
中的参数
使用多智能体框架AgentScope制作应用,需要配置
model_config
,即模型的配置,以方便后续设计Agent时使用对应模型,
model_config
中的参数如下:
model_type
:
对应
ModelWrapper
的类型,不同
model_type
需要填的
model_config
内容不同
◦
有
固定的几个type,
支持的API列表
可
见
官方文档
。
示意图
◦
举例:如果
model_type
为
openai
,那么它内部会找到
agentscope\src\agentscope\models\openai_model.py
文件里面的class。具体实现可以看源码。
config_name
:相当于自己定义的一个配置的名字
◦
后面设置Agent的
model_config_name
会与model进行绑定
。
model_name
:使用模型的名称
api_key
:
调用模型API服务的秘钥,
需要去对应的平台申请。
大模型的配置
•
通义千问
代码块
Python
import agentscope
agentscope.init(
model_configs={
"model_type": "
dashscope_chat
",
"config_name": "qwen",
"model_name": "qwen-max",
"api_key": "
sk-
",
"generate_args": {
"temperature": 0.5
}
}
)