基于Conda的OpenAgents入门指南

核心概念

安装Conda环境

Anaconda官网下载,Anaconda的完整版或者MiniConda均可

bash 复制代码
# 创建Conda环境
conda create -n openagents python=3.12

# 激活conda环境
conda activate openagents

# 安装UV管理
pip install uvicorn

# 安装openagents
uv pip install -U openagents

获取项目

bash 复制代码
git clone https://github.com/openagents-org/openagents.git
cd openagents

# openagents studio -s前, 需要先构建studio项目

cd studio
npm install
npm run build

创建网络

bash 复制代码
# 创建网络
openagents network init ./my_first_network

# 启动网络
openagents network start ./my_first_network

# 启动网络可视化
openagents studio -s

Agent连接到网络

前置设置及问题

1、密钥设置及问题,Windows/Mac/Linux

bash 复制代码
# Windows
# Must: set deepseek_api_key
$env:DEEPSEEK_API_KEY="your-key-here"

# Mac/Linux设置命令
# Optional: Set the OpenAI base URL
export OPENAI_BASE_URL="your-base-url-here"
 
# Must: Set the OpenAI API key
export OPENAI_API_KEY="your-key-here"

2、Windows关于编码问题,运行会报错:

bash 复制代码
openagents\Lib\logging\__init__.py", line 1163, in emit
    stream.write(msg + self.terminator)
UnicodeEncodeError: 'gbk' codec can't encode character '\U0001f527' in position 0: illegal multibyte sequence

解决方案:将系统编码改为UTF-8,再重启电脑。重新尝试。

  • 按下【Win】键,输入"设置"并打开。
  • 在设置窗口中,点击"时间和语言"。
  • 在"时间和语言"设置中,点击"语言"菜单项。
  • 在"语言"设置中,点击"管理语言设置"。
  • 在"区域"窗口中,选择"管理"选项卡。
  • 点击"更改系统区域设置"按钮。
  • 在"区域设置"对话框中,勾选"Beta 版:使用Unicode UTF-8提供全球语言支持(U)"复选框。
  • 点击"确定"按钮保存更改。

基于YAML的Agents

bash 复制代码
# 激活conda环境
conda activate openagents

# 启动Agent
openagents agent start ./my_first_network/agents/charlie.yaml

基于Python的Agents

bash 复制代码
# 激活conda环境
conda activate openagents

# llm的Agent
python ./my_first_network/agents/llm_agent.py

# 无llm的Agents
python ./my_first_network/agents/simple_agent.py

OpenAgents Demo

00_hello_world: 一个客服回复消息
bash 复制代码
# 激活conda环境
conda activate openagents

# 启动网络, HTTP: 8700 , gRPC: 8600
openagents network start demos/00_hello_world/

# 启动代理
openagents agent start demos/00_hello_world/agents/charlie.yaml

# 连接Studio, 导航到http://localhost:8050 并连接到 localhost:8700
openagents studio -s
01_startup_pitch_room: 与创始人、工程师和投资者的多代理角色扮演
  • founder: 远见企业家角色
  • engineer: 技术联合创始人角色
  • investor: 投资者角色
bash 复制代码
# 激活conda环境
conda activate openagents

# 启动网络
openagents network start demos/01_startup_pitch_room

# 启动创始人角色
openagents agent start demos/01_startup_pitch_room/agents/founder.yaml

# 启动工程师代理
openagents agent start demos/01_startup_pitch_room/agents/engineer.yaml

# 启动投资者代理
openagents agent start demos/01_startup_pitch_room/agents/investor.yaml

# 启动Studio
openagents studio -s
02_tech_news_stream: HackNews与Python WorkAgent集成
  • news-hunter: 新闻猎人角色
  • commentator: 解说员
bash 复制代码
# 激活conda环境
conda activate openagents

# 启动网络
openagents network start demos/02_tech_news_stream/

# 启动新闻猎人代理
python demos/02_tech_news_stream/agents/news_hunter.py

python demos/02_tech_news_stream/agents/news_hunter.py --interval 120 --host localhost --port 8700

# 启动解说员代理
openagents agent start demos/02_tech_news_stream/agents/commentator.yaml
03_research_team: 基于路由器的任务委派,使用项目模组
  • router: 协调员角色,接受请求、委派任务、汇总结果
  • web-searcher: 信息收集者角色,网络搜索,黑客新闻查询
  • analyst: 合成器,分析与结论
bash 复制代码
# 激活conda环境
conda activate openagents

# Windows
# Must: set deepseek_api_key
$env:OPENAI_API_KEY="your-key-here"
$env:OPENAI_BASE_URL="your-base-url-here"
$env:BRAVE_API_KEY="your-key-here"

# Mac/Linux设置命令
# LLM API KEY
export OPENAI_API_KEY="your-key-here"
export OPENAI_BASE_URL="your-base-url-here"
# BRAVE API KEY
export BRAVE_API_KEY="your-key-here"

# 启动网络
openagents network start demos/03_research_team/

# 启动路由器
openagents agent start demos/03_research_team/agents/router.yaml

# 启动网络搜索器
openagents agent start demos/03_research_team/agents/web_searcher.yaml

# 启动分析师
openagents agent start demos/03_research_team/agents/analyst.yaml

# 启动studio
openagents studio -s
04_grammar_check_forum: 带有自动语法检查功能的论坛
  • 语法错误
  • 拼写错误
  • 标点符号
  • 句子结构
  • 用词
  • 风格建议
bash 复制代码
# 激活conda环境
conda activate openagents

# Windows
# Must: set deepseek_api_key
$env:OPENAI_API_KEY="your-key-here"
$env:OPENAI_BASE_URL="your-base-url-here"

# Mac/Linux设置命令
# Optional: Set the OpenAI base URL
export OPENAI_BASE_URL="your-base-url-here"
# Must: Set the OpenAI API key
export OPENAI_API_KEY="your-key-here"

# 启动网络
openagents network start demos/04_grammar_check_forum/

# 启动语法检查器
openagents agent start demos/04_grammar_check_forum/agents/grammar_checker.yaml

参考

1️⃣ 教程:5 个 Demo 入门OpenAgents

文档:https://mp.weixin.qq.com/s/RX-JF4rLoLTN_P-R2TWYuA

视频:https://www.bilibili.com/video/BV1FkqhB1EV9/?share_source=copy_web\&vd_source=39df78e18dca1725b6737946144dded3

GitHub:https://github.com/openagents-org/openagents

新手入门教程:https://openagents.org/docs/tutorials/tutorials

OpenAgents 官网:https://openagents.org

相关推荐
熊猫钓鱼>_>4 天前
多智能体协作:构建下一代高智能应用的技术范式
人工智能·ai·去中心化·wpf·agent·多智能体·multiagent
KAI智习14 天前
一张图看懂AI Agent的6种模式—MAS
人工智能·agent·多智能体·mas
小小工匠20 天前
LLM - AI Agent 学习路线图:从 RAG 到多智能体实战
人工智能·多智能体·rag
YuanDaima20482 个月前
[CrewAI] 第5课|基于多智能体构建一个 AI 客服支持系统
人工智能·笔记·多智能体·智能体·crewai
一个处女座的程序猿2 个月前
LLMs之MultiAgent:OpenAgents(创建AI智能体网络)的简介、安装和使用方法、案例应用之详细攻略
llms·openagents
小新学习屋2 个月前
大模型-智能体-【篇二:多智能体框架】
大模型·多智能体
皇族崛起3 个月前
金融 - 搭建 图谱挖掘工作流 调研
金融·llm·知识图谱·neo4j·多智能体·findpaper
booooooty6 个月前
基于Spring AI Alibaba的多智能体RAG应用
java·人工智能·spring·多智能体·rag·spring ai·ai alibaba
技术便签7 个月前
第一篇:Agent2Agent (A2A) 协议——协作式人工智能的黎明
人工智能·python·ai编程·agi·多智能体·智能体·adk