Proteus 是一款强大的、可扩展的、基于 Python 和 FastAPI 的多智能体工作流引擎。它旨在提供一个灵活且高效的平台,用于构建和管理复杂的自动化任务和智能代理系统。通过集成各种工具,支持灵活的工作流编排和多智能体协作,Proteus 赋予用户从数据收集和分析到决策执行的全流程自动化能力。
Proteus 来源于希腊神话中的海神,以其随意变换形态的能力而闻名。这个名称完美地契合了该项目的核心特性:
Proteus 引擎提供了以下核心功能,以满足您的自动化和智能代理需求:
内置超过 20 种节点类型,涵盖各种操作,并支持轻松扩展:
file_read,file_write)、数据库操作(db_query,db_execute)。duckduckgo_search,arxiv_search,serper_search)、网络爬虫(web_crawler,web_crawler_local)。python_execute)、终端命令执行(terminal)、浏览器自动化(browser_agent)。api_call)、聊天(chat)、用户输入(user_input)、邮件发送(email_sender)。weather_forecast)、MCP 客户端(mcp_client)、团队生成(team_generator)、工作流生成(workflow_generate)。请查看 examples 文件夹中的示例研究报告,展示 Proteus 在复杂信息收集和分析方面的能力:
克隆项目
git clone https://github.com/yourusername/proteus-ai.git
cd proteus-ai
创建并激活虚拟环境
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
安装核心依赖
pip install -r proteus/requirements.txt
配置环境变量
复制 .env.example 到 .env 并根据需要编辑 .env 文件,设置必要的环境变量(如 API_KEY)。
cp .env.example .env
浏览器自动化依赖(可选)
如果需要浏览器自动化功能(如 browser_agent 或 web_crawler_local),请安装 Playwright:
playwright install
# 确保已安装所有依赖
pip install -r proteus/requirements.txt
playwright install # 如果需要浏览器自动化功能
# 启动服务
python proteus/main.py
服务启动后,访问 http://localhost:8000 可打开网页界面。
# 构建 Docker 镜像(在项目根目录执行)
docker build -t proteus -f proteus/Dockerfile .
# 使用 Docker Compose 启动所有服务
docker-compose -f proteus/docker/docker-compose.yml up -d
服务启动后,访问 http://localhost:8000 可打开网页界面,或者通过 https://localhost:9443 访问位于 Nginx 代理后面的 HTTPS 服务。
此项目提供了一个强大的命令行工具,使开发者和用户可以直接在终端中与 Proteus AI 系统交互。
# 安装 CLI 依赖
pip install -r cli/requirements_cli.txt
# 运行 CLI 工具进行聊天
python cli/proteus-cli.py chat "你好"
cli/CLI_README.md。主要配置项在 .env 文档中,需从 .env.example 复制并配置:
API_KEY:LLM API 密钥(必需)。MODEL_NAME:使用的模型名称(默认为 deepseek-chat)。REASONER_MODEL_NAME:推理模型名称(可选)。SERPER_API_KEY:用于网络搜索的 Serper API 密钥(可选)。MCP_CONFIG_PATH:MCP 配置文件路径(默认为 ./proteus/proteus_mcp_config.json)。REDIS_HOST:Redis 服务器地址(默认为 localhost)。REDIS_PORT:Redis 服务器端口(默认为 [6379])。REDIS_DB:Redis 数据库索引(默认为 0)。REDIS_PASSWORD:Redis 密码(可选)。SANDBOX_URL:沙箱服务 URL(默认为 http://localhost:8001)。这是一个简单的研究工作流示例,用于收集和分析主题信息:
name: 简单研究流程
description: 一个简单的研究工作流示例
nodes:
- type: user_input
id: input
params:
question: "请输入研究主题"
- type: duckduckgo_search
id: search
params:
query: "{{input.output}}"
max_results: 5
- type: web_crawler
id: crawler
params:
urls: "{{search.output}}"
- type: chat
id: analysis
params:
prompt: |
请基于以下内容进行分析总结:
{{crawler.output}}
- type: file_write
id: output
params:
path: "./research_output.md"
content: "{{analysis.output}}"
此示例演示如何使用 mcp_client 节点调用外部 MCP 服务器提供的工具来查询天气。
name: 天气查询
description: 使用MCP工具查询天气
nodes:
- type: user_input
id: input
params:
question: "请输入城市名称"
- type: mcp_client
id: weather
params:
server_name: "amap-maps" # 假设已配置名为 "amap-maps" 的 MCP 服务器
tool_name: "maps_weather" # 调用该服务器上的 "maps_weather" 工具
arguments: |
{
"city": "{{input.output}}"
}
- type: chat
id: format
params:
prompt: |
将天气数据格式化为友好回复:
{{weather.output}}
proteus/src/nodes/ 目录下创建一个新的节点文件。BaseNode 类并实现必要的方法。proteus/src/nodes/node_config.yaml 中注册节点配置。proteus/src/agent/prompt/ 中间添加新的提示模板。proteus/src/agent/agent.py 实现新的推理方法。proteus/static/ 目录。const eventSource = new EventSource(`/stream/${chatId}`);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
// 处理实时数据
};
python -m pytest tests/unit/python -m pytest tests/integration/python -m pytest tests/e2e/配置 MCP 服务器:
在 proteus/proteus_mcp_config.json 中间配置 MCP 服务器信息,例如:
{
"mcpServers": {
"server-name": {
"type": "sse",
"url": "https://your-mcp-server-url"
}
}
}
在代码中使用 MCP 管理器:
from proteus.src.manager.mcp_manager import get_mcp_manager, initialize_mcp_manager
# 初始化 MCP 管理器
await initialize_mcp_manager()
# 获取 MCP 管理器实例
mcp_manager = get_mcp_manager()
# 获取所有工具
tools = mcp_manager.get_all_tools()
# 获取所有资源
resources = mcp_manager.get_all_resources()
在代理中使用 MCP 工具:
我们致力于不断改进 Proteus 引擎,以下是未来可能优先考虑的功能和优化:
欢迎提交 Issue 和 Pull Request 来帮助改进项目。在提交代码之前,请确保:
本项目采用 MIT 许可证,详情见 LICENSE 文档。