多接口AI代理
一个灵活的AI代理系统,支持Discord机器人、终端CLI和语音转文本界面。内置MCP(模型上下文协议)集成,用于可扩展的工具调用和任务自动化。
特性
多个接口
- 用激活词和会话超时来扰乱机器人程序
- 用于直接交互的终端CLI
- 使用Whisper进行语音转文本输入(可选)
- 并发操作(同时运行CLI和Discord bot)
AI模型支持
- Ollama(当地模特)
- 谷歌双子星
- Azure人工智能推理
- GitHub模型API
综合技能
- 谷歌日历管理
- Gmail操作
- GitHub存储库交互
- 网络搜索(LangSearch)
- PowerShell命令执行
- 矢量存储(松果)
- 用于持久笔记的黑板
- 简历/文档解析
MCP集成
- 可扩展工具系统的模型上下文协议客户端
- 动态工具发现和执行
- 支持自定义MCP服务器
安装
- 克隆存储库并导航到项目目录
- 创建虚拟环境:
python -m venv .venv
.venv\Scripts\Activate.ps1- 安装依赖项:
pip install -r requirements.txt- 配置环境变量:
- 复制 .env.example 到 .env - 填写所需的凭据(请参阅配置部分)
配置
所需的环境变量
模型提供商 (选择一个):
MODEL_PROVIDER=ollama # Options: ollama, gemini, azure, github
OLLAMA_MODEL=gpt-oss:120b # For Ollama
OLLAMA_ENDPOINT=https://ollama.com
GEMINI_API_KEY=your_key # For Gemini
GITHUB_TOKEN=your_token # For GitHub Models or GitHub skill谷歌服务 (日历/Gmail技能):
GOOGLE_APPLICATION_CREDENTIALS=env/google.json
GOOGLE_TOKEN_FILE=env/token.json
GOOGLE_DEFAULT_EMAIL=your_email@gmail.com
GOOGLE_CALENDAR_ID=primary
GOOGLE_CALENDAR_TIMEZONE=Asia/Hong_KongDiscord机器人 (可选):
DISCORD_BOT_TOKEN=your_discord_token
DISCORD_USER_ID=123456789 # Optional: restrict to specific user
ACTIVATION_WORD=hey # Word to activate the bot
ACTIVATION_TIMEOUT=60 # Auto-deactivate after N seconds矢量存储器 (可选):
PINECONE_API_KEY=your_key
PINECONE_INDEX_NAME=agent-memory
PINECONE_NAMESPACE=agent
PINECONE_DIMENSION=1536文件位置
将身份验证文件放入 env/ 目录:
google.json-Google服务帐户凭据token.json-日历/Gmail的OAuth令牌vectors.json-本地矢量存储(自动创建)runtime_state.json-运行时配置(自动创建)
运行应用程序
从工作区根目录:
python system\main.py # CLI + Discord bot (if token set)
python system\main.py --no-cli # Discord bot only
python system\main.py --bot # Force Discord bot mode使用批处理文件 (Windows):
system\run.bat # Runs in background using pythonw.exe激活:
- Discord:发送一条包含您的激活词的消息(默认:“嘿”)
- CLI:在提示符处直接键入
- 演讲:启用
ENABLE_SPEECH_ON_START=true
项目结构
system/ Main application modules
main.py Entry point and interface orchestration
agent.py Core agent logic with MCP integration
bridge.py Shared interface abstraction layer
cli.py Terminal CLI interface
discord_bot.py Discord bot interface
speech.py Speech-to-text interface
model.py LLM client implementations
log.py Logging utilities
skills/ Agent capabilities and integrations
calender.py Google Calendar operations
gmail.py Gmail operations
github.py GitHub API integration
search.py Web search functionality
memory.py Vector memory storage
blackboard.py Persistent note system
powershell.py PowerShell command execution
mcp_server.py MCP server management
runtime_state.py Runtime configuration
prompts/ System prompts and instructions
system.py Base system prompt configuration
env/ Credentials and runtime data
google.json Google service account (gitignored)
token.json OAuth tokens (gitignored)
vectors.json Vector embeddings (gitignored)
runtime_state.json Runtime state (gitignored)用法示例
Discord Bot:
- 邀请机器人到您的服务器
- 发送:“嘿,今天我的日历上有什么?”
- Bot激活并响应
- 超时后会话自动停用
终端CLI:
> analyze my recent GitHub commits
> send an email to john@example.com about the meeting
> search for information about MCP protocol
> stop语音输入: 启用环境变量,并在语音活动检测触发后自然说话。
备注
- 代理在多个回合中维护对话上下文
- MCP服务器在启动时初始化,并提供动态工具
- 可以使用“leave”命令重置会话
- 使用“停止”优雅地终止应用程序
- 日志输出被写入
agent_output.log在工作区根目录中
依赖项
核心要求:Python 3.10+、azure ai推理、disconfirm.py、谷歌genai、mcp、ollama
看 requirements.txt 获取完整的依赖关系列表。
