智能对话助手,支持多MCP服务、流式语音交互、主题树检索、RESTful API接口、极致精简代码风格。
克隆项目
git clone [项目地址]
cd NagaAgent
一键配置
Windows:
.\setup.ps1
Mac:
chmod +x quick_deploy_mac.sh
./quick_deploy_mac.sh
启动
Windows:
.\start.bat
Mac:
./start_mac.sh
启动后将自动开启PyQt5界面和RESTful API服务器,可同时使用界面对话和API接口。
requirements.txt
greenlet
、pyaudio
等安装失败,需先装Microsoft Visual C++ Build Tools,勾选C++ build tools,重启命令行后再pip install -r requirements.txt
playwright
,首次用需python -m playwright install chromium
python -m venv .venv
.venv\Scripts\Activate
pip install -r requirements.txt
python -m playwright install chromium
# 安装基础依赖
brew install [email protected] portaudio
brew install --cask google-chrome
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python -m playwright install chromium
brew install portaudio
pip install pyaudio
python check_env.py
直接修改 config.py
文件中的配置:
DEEPSEEK_API_KEY = "<your_deepseek_api>"
在 config.py
中可配置API服务器相关参数:
API_SERVER_ENABLED = True # 是否启用API服务器
API_SERVER_HOST = "127.0.0.1" # API服务器主机
API_SERVER_PORT = 8000 # API服务器端口
API_SERVER_AUTO_START = True # 启动时自动启动API服务器
config.py
或 .env
文件config.py
管理,支持.env和环境变量,所有变量唯一、无重复定义config.py
统一管理\n
还是\\n
,PyQt界面都能正确分行显示mcpserver/mcp_registry.py
,主流程和管理器极简,扩展维护更方便。只需维护一处即可批量注册/扩展所有Agent服务。NagaAgent/
├── main.py # 主入口
├── config.py # 全局配置
├── conversation_core.py # 对话核心(含工具调用循环主逻辑)
├── apiserver/ # API服务器模块
│ ├── api_server.py # FastAPI服务器
│ ├── start_server.py # 启动脚本
│ └── README.md # API文档
├── agent/ # 预处理系统模块
│ ├── preprocessor.py # 消息预处理
│ ├── plugin_manager.py # 插件管理
│ ├── api_server.py # 代理API服务器
│ ├── image_processor.py # 图片处理
│ ├── start_server.py # 启动脚本
│ └── README.md # 预处理系统文档
├── mcpserver/
│ ├── mcp_manager.py # MCP服务管理
│ ├── mcp_registry.py # Agent注册与schema元数据
│ ├── agent_xxx/ # 各类自定义Agent(如file、coder、browser等)
├── requirements.txt # 依赖
├── setup.ps1 # Windows配置脚本
├── start.bat # Windows启动脚本
├── setup_mac.sh # Mac配置脚本
├── quick_deploy_mac.sh # Mac一键部署脚本
├── check_env.py # 跨平台环境检查
├── summer/ # faiss与向量相关
│ ├── memory_manager.py # 记忆管理主模块
│ ├── summer_faiss.py # faiss相关操作
│ ├── faiss_index.py # faiss索引管理
│ ├── embedding.py # 向量编码
│ ├── memory_flow/ # 记忆分层相关
│ └── summer_upgrade/ # 兼容升级相关脚本
│ └── compat_txt_to_faiss.py # 历史对话兼容主脚本
├── logs/ # 日志(含历史txt对话)
│ ├── 2025-04-27.txt
│ ├── 2025-05-05.txt
│ ├── ...
│ └── faiss/ # faiss索引与元数据
├── voice/ # 语音相关
│ ├── voice_config.py
│ └── voice_handler.py
├── ui/ # 前端UI
│ ├── pyqt_chat_window.py # PyQt聊天窗口
│ └── response_utils.py # 前端通用响应解析工具
├── models/ # 向量模型等
├── README.md # 项目说明
└── ...
系统仅支持如下格式的工具调用:
<<<[TOOL_REQUEST]>>>
tool_name: 「始」服务名称「末」
param1: 「始」参数值1「末」
param2: 「始」参数值2「末」
<<<[END_TOOL_REQUEST]>>>
# config.py中的工具调用循环配置
MAX_VCP_LOOP_STREAM = 5 # 流式模式最大工具调用循环次数
MAX_VCP_LOOP_NON_STREAM = 5 # 非流式模式最大工具调用循环次数
SHOW_VCP_OUTPUT = False # 是否显示工具调用输出
# 浏览器操作
await mcp.handoff(
service_name="playwright",
task={"action": "open_browser", "url": "https://www.bilibili.com"}
)
# 文件操作
await mcp.handoff(
service_name="file",
task={"action": "read", "path": "test.txt"}
)
# 代码执行
await mcp.handoff(
service_name="coder",
task={"action": "run", "file": "main.py"}
)
mcpserver/mcp_registry.py
,批量管理,极简扩展# 读取文件内容
await s.mcp.handoff(
service_name="file",
task={"action": "read", "path": "test.txt"}
)
# 运行Python代码
await s.mcp.handoff(
service_name="coder",
task={"action": "run", "file": "main.py"}
)
ui/response_utils.py
的extract_message
方法自动适配多种返回格式data.content
,其次message
,最后原样返回,兼容所有Agent\n
和\\n
换行符转为<br>
,多行内容显示无障碍config.py
和pyqt_chat_window.py
灵活配置voice/voice_config.py
和README相关章节config.py
统一管理,便于灵活调整config.py
#夏园系统兼容升级
summer/summer_upgrade/history_dialogs.json
。python summer/summer_upgrade/compat_txt_to_faiss.py import all
python summer/summer_upgrade/compat_txt_to_faiss.py import 1,3,5-8
python check_env.py
setup.ps1
与本READMEbrew install [email protected]
brew install portaudio && pip install pyaudio
chmod +x *.sh
config.py
中的API_SERVER_PORT
unset ALL_PROXY http_proxy https_proxy
pip install fastapi uvicorn[standard]
config.py
中的MAX_VCP_LOOP_STREAM
和MAX_VCP_LOOP_NON_STREAM
config.py
统一管理#devmode
进入开发者模式,后续对话不写入faiss,仅用于工具调用测试MIT License
如需详细功能/API/扩展说明,见各模块注释与代码,所有变量唯一、注释中文、极致精简。
config.BG_ALPHA
统一控制,取值0~1,默认0.4。config.USER_NAME
,如需自定义可直接修改该变量。ui/pyqt_chat_window.py
的toggle_full_img
方法中自定义。LLM必须严格按照以下格式输出工具调用:
<<<[TOOL_REQUEST]>>>
tool_name: 「始」服务名称「末」
param1: 「始」参数值1「末」
param2: 「始」参数值2「末」
<<<[END_TOOL_REQUEST]>>>
# config.py中的工具调用循环配置
MAX_VCP_LOOP_STREAM = 5 # 流式模式最大工具调用循环次数
MAX_VCP_LOOP_NON_STREAM = 5 # 非流式模式最大工具调用循环次数
SHOW_VCP_OUTPUT = False # 是否显示工具调用输出
如需添加新的工具调用处理逻辑,可以:
mcpserver/
目录下添加新的Agentmcpserver/mcp_registry.py
中注册新AgentNagaAgent内置完整的RESTful API服务器,启动时自动开启,支持所有对话功能:
http://127.0.0.1:8000
(可在config.py中配置)http://127.0.0.1:8000/docs
http://127.0.0.1:8000/openapi.json
GET /health
# 普通对话
POST /chat
{
"message": "你好,娜迦",
"session_id": "optional-session-id"
}
# 流式对话 (Server-Sent Events)
POST /chat/stream
{
"message": "请介绍一下人工智能的发展历程"
}
# 获取系统信息
GET /system/info
# 切换开发者模式
POST /system/devmode
# 获取记忆统计
GET /memory/stats
# 获取MCP服务列表
GET /mcp/services
# 调用MCP服务
POST /mcp/handoff
{
"service_name": "file",
"task": {
"action": "read",
"path": "test.txt"
}
}
# 基本对话
curl -X POST "http://127.0.0.1:8000/chat" \
-H "Content-Type: application/json" \
-d '{"message": "你好,娜迦"}'
# 流式对话
curl -X POST "http://127.0.0.1:8000/chat/stream" \
-H "Content-Type: application/json" \
-d '{"message": "请介绍一下人工智能"}' \
--no-buffer
API使用标准HTTP状态码:
200
- 成功400
- 请求参数错误500
- 服务器内部错误503
- 服务不可用如果您的环境中配置了代理(如SOCKS代理),测试本地API时可能需要临时禁用:
# 临时禁用代理
unset ALL_PROXY http_proxy https_proxy
# 然后测试API
curl http://127.0.0.1:8000/health
open
:打开指定应用list
:列出所有可用应用refresh
:刷新应用缓存参数名 | 类型 | 说明 | 是否必填 |
---|---|---|---|
action | string | 操作类型(open/list/refresh) | 是 |
app | string | 应用名或路径(open时必填) | 否 |
args | array | 启动参数(可选) | 否 |
{"action": "open", "app": "微信"}
{"action": "list"}
{"action": "refresh"}
list
操作确认缓存中真实的应用名。refresh
再open
。本系统仅支持如下格式的工具调用循环:
<<<[TOOL_REQUEST]>>>
tool_name: 「始」服务名称「末」
param1: 「始」参数值1「末」
param2: 「始」参数值2「末」
<<<[END_TOOL_REQUEST]>>>
如无需调用工具,直接回复message字段内容即可。
No configuration available
Related projects feature coming soon
Will recommend related projects based on sub-categories