MiniMax代理聊天机器人
一个全面的人工智能聊天机器人,具有todo管理、XFCE桌面集成和代理任务执行功能。
🌟 特性
🤖 智能聊天界面
- 与人工智能的自然语言对话
- 实时WebSocket通信
- 对话历史和记忆
- 情境响应和帮助
✅ 待办事项管理系统
- 创建、更新和删除待办事项
- 将任务标记为已完成/未完成
- 优先级和时间戳
- 持久SQLite数据库存储
🖥️ XFCE桌面集成
- 完整的XFCE桌面环境流
- 用于远程桌面访问的VNC服务器
- 屏幕截图功能
- 通过聊天命令进行桌面控制
🏃 代理任务执行
- 执行shell命令
- 文件系统操作
- 网络搜索和浏览
- 自动化任务调度
- 行动结果跟踪
🌐 web界面
- 基于React的现代聊天UI
- 实时待办事项控制面板
- 代理操作监视器
- 移动/桌面响应式设计
🔗 多服务架构
- Web前端:React聊天界面(端口5173)
- API服务器:FastAPI后端(端口8000)
- 🕐 MCP时间:时间和时区服务(端口8001)
- 🕸️ MCP剧作家:浏览器自动化(端口8002)
- 🧠 MCP思维:顺序推理(端口8003)
- 🔍 MCP搜索:DuckDuckGo搜索(端口8004)
- 被控端:桌面流媒体(端口5900)
- Chrome CDP:浏览器自动化(端口9222)
- Websockify:VNC到WebSocket网桥(端口8080)
🤖 MCP(模型上下文协议)集成
- 时间管理:获取当前时间、时区信息、日期计算
- 浏览器自动化:截图、网页导航、数据提取
- 顺序思维:问题分析,逐步推理
- 网页搜索:DuckDuckGo集成,提供即时答案和搜索结果
🚀 快速开始
方法1:本机安装(Termux/Linux)
# Clone the repository
git clone
cd chatbot_project
# Install dependencies
pip install -r requirements.txt
# Start all services
chmod +x manage.sh
./manage.sh start
# Or use the Python launcher
python run.py方法二:Docker部署
# Build and run with Docker Compose
docker-compose up -d
# Check service status
docker-compose ps
# View logs
docker-compose logs -f方法3:手动启动服务
# Start backend API (Terminal 1)
python chatbot.py
# Start frontend server (Terminal 2)
cd frontend && python -m http.server 5173
# Start VNC server (Terminal 3)
x11vnc -display :1 -rfbport 5900 -forever
# Start Chrome CDP (Terminal 4)
google-chrome --headless --remote-debugging-port=9222 --no-sandbox📱 接入点
🌐 web界面
- 统一资源定位符: http://localhost:5173
- 描述:带有待办事项、桌面控制和代理操作的主聊天界面
🔗 API文档
- 统一资源定位符: http://localhost:8000/docs
- 描述:交互式API文档和测试
🕐 MCP时间服务
- 统一资源定位符: http://localhost:8001
- 描述:时间和时区管理服务
🕸️ MCP编剧服务
- 统一资源定位符: http://localhost:8002
- 描述:浏览器自动化和截图服务
🧠 MCP思维服务
- 统一资源定位符: http://localhost:8003
- 描述:顺序推理和分析服务
🔍 MCP搜索服务
- 统一资源定位符: http://localhost:8004
- 描述:DuckDuckGo搜索和即时应答服务
🖥️ VNC桌面
- 主机:本地主机
- 端口: 5900
- 密码: 123456
- 描述:访问XFCE桌面环境
🌐 Websockify桥
- 统一资源定位符: http://localhost:8080
- 描述:用于基于web的VNC客户端的VNC到WebSocket桥
🌐 Chrome工具
- 统一资源定位符: http://localhost:9222
- 描述:Chrome DevTools协议接口
💬 聊天指令
待办事项管理
add todo [task] # Create a new todo
list todos # Show all todos
complete todo [id] # Mark todo as complete
delete todo [id] # Remove todo代理操作
execute command [command] # Run shell command
search [query] # Web search
file read [path] # Read file content
file write [path] [content] # Write to file桌面控制
screenshot # Capture desktop screenshot
start desktop # Launch XFCE session
show vnc # Display VNC connection info
open terminal # Open terminal in desktopMCP服务命令
current time [timezone] # Get current time
time EST # Get time in specific timezone
think about [problem] # Analyze problem with reasoning
analyze [question] # Get detailed analysis
screenshot web [url] # Take webpage screenshot
what is [question] # Get instant answer
search [query] # Enhanced web search一般对话
help # Show available commands
status # Check service status
hello # Greeting response🏗️ 建筑
后端组件
FastAPI服务器 (chatbot.py)
- RESTful API端点
- WebSocket实时通信
- 会话管理
- 数据库操作
数据库层 (Database 类)
- SQLite数据库管理
- 待办事项、聊天和动作存储
- 查询优化和索引
聊天引擎 (ChatManager 类)
- 消息处理
- 意图识别
- 响应生成
- 对话历史
代理执行人 (AgentExecutor 类)
- 命令执行
- 文件 操作
- Web自动化
- 行动跟踪
XFCE控制器 (XFCEController 类)
- 桌面环境管理
- 屏幕截图
- VNC服务器控制
前端组件
React Web界面 (index.html)
- 聊天信息显示
- Todo仪表板
- 代理操作监视器
- 实时更新
WebSocket客户端
- 实时通信
- 消息广播
- 连接管理
🛠️ 发展
目录结构
chatbot_project/
├── chatbot.py # Main application
├── run.py # Startup script
├── manage.sh # Service management
├── requirements.txt # Python dependencies
├── .env # Configuration
├── Dockerfile # Docker image
├── docker-compose.yml # Docker orchestration
├── frontend/
│ └── index.html # Web interface
├── logs/ # Application logs
├── data/ # Database and storage
└── pids/ # Process IDs配置
环境变量 .env:
DATABASE_PATH:SQLite数据库位置WEB_PORT:前端服务器端口API_PORT:后端API端口VNC_PORT:桌面流媒体端口CHROME_CDP_PORT:浏览器自动化端口
服务管理
# Check service status
./manage.sh status
# View logs
./manage.sh logs
./manage.sh logs api
# Health checks
./manage.sh health
# Stop all services
./manage.sh stop
# Restart services
./manage.sh restartMCP服务管理
# Start all MCP services
./mcp-manage.sh start
# Stop all MCP services
./mcp-manage.sh stop
# Check MCP service status
./mcp-manage.sh status
# Health check all MCP services
./mcp-manage.sh health
# Test MCP service integration
python test_mcp.py
# Setup development environment
./mcp-manage.sh setup🔧 定制
添加新命令
扩展 ChatBot 类在 chatbot.py:
async def _handle_custom_command(self, message: str) -> str:
# Add your custom logic here
return "Custom command response"修改Todo系统
更新 TodoManager 要添加的类:
- 分类及标签
- 到期日期和提醒
- 优先级
- 文件附件
桌面集成
增强 XFCEController 班级:
- 应用程序启动
- 窗口管理
- 系统监控
- 定制自动化
🐛 故障排除
常见问题
端口已在使用中
# Kill process on port
lsof -ti:8000 | xargs kill -9
# Or use the service manager
./manage.sh stopVNC连接问题
- 检查VNC服务器是否正在运行:
netstat -tulpn | grep 5900 - 验证密码:默认值为
123456 - 检查防火墙设置
Chrome CDP错误
- 确保Chrome已安装:
google-chrome --version - 检查Chrome进程:
ps aux | grep chrome - 验证端口可访问性:
curl http://localhost:9222
数据库错误
# Reset database
rm chatbot.db
python run.py # Will recreate database日志分析
# View recent logs
tail -f logs/chatbot.log
# Check service-specific logs
./manage.sh logs api
./manage.sh logs vnc📊 性能监控
资源使用情况
- 监控CPU和内存使用情况
- 检查数据库大小和查询
- 跟踪WebSocket连接
- 监控日志的磁盘空间
缩放注意事项
- 使用Redis进行会话存储
- 实现消息队列
- 添加负载平衡
- 考虑将数据库迁移到PostgreSQL
🔐 安全
当前安全措施
- 地方发展重点
- CORS配置
- 输入验证
- SQL注入预防
生产建议
- 使用环境变量作为机密
- 实施身份验证
- 启用HTTPS
- 添加速率限制
- 定期安全更新
🤝 贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 彻底测试
- 提交拉取请求
开发环境设置
# Install development dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Run tests
python -m pytest tests/
# Code formatting
black *.py
flake8 *.py📄 许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
🙏 致谢
- 安卓Linux环境下的Termux项目
- 优秀web框架的FastAPI
- XFCE适用于轻量级桌面环境
- VNC用于远程桌面功能
- React和Tailwind CSS用于现代UI
📞 支持
对于问题和疑问:
- 检查故障排除部分
- 查看应用程序日志
- 在GitHub上打开一个问题
- 联系开发团队
______________________________________________________________________
MiniMax代理聊天机器人 -您的智能助手,用于生产力、自动化和桌面集成! 🤖✨
