生产力助手

一个基于Strands Agents的生产力助手,具有原生MCP集成和多工具协调功能,适用于笔记管理、任务处理、视频分析和视觉系统等多种场景。

  • by ludocarceles
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 carssou/assistant

使用说明

Strands代理商生产力助理

Strands Agents驱动的生产力助手,具有原生MCP集成和多工具协调功能。该代理将本机工具与MCP服务器无缝结合,以实现最佳性能和灵活性。

特性

  • 📝 笔记管理:原生黑曜石保险库与10个优化的纸币操作集成
  • 🔍 以隐私为中心的搜索:SearXNG集成用于安全网络研究
  • ✅ 任务管理:Todoist集成,实现全面的任务处理
  • 🎥 视频分析:通过智能摘要增强YouTube处理
  • 👁️ 视觉系统:支持超宽显示器的多模型屏幕截图分析(Claude、OpenAI、Amazon Nova)
  • ⚡ Strands建筑:本地MCP集成自动工具发现和健康监测
  • 🛡️ 错误处理:当工具不可用时,性能会下降
  • 🌐 现代界面:具有实时流媒体和会话管理的流线型GUI
  • 🔧 模型灵活性:在AWS Bedrock、Anthropic和OpenAI提供商之间轻松切换

需求

  • Python 3.8+
  • Docker和Docker Compose(用于SearXNG网络搜索)
  • Git

快速开始

1.设置环境

# Clone the repository
git clone https://github.com/Carssou/assistant.git
cd assistant

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

2.启动SearXNG(网络搜索)

# Start SearXNG Docker container for web search functionality
docker-compose up -d

这将在以下位置启动一个本地SearXNG实例 http://localhost:8080 启用JSON API。

3.配置环境变量

cp .env.example .env
# Edit .env with your API keys and configurations

所需配置:

# LLM Configuration
LLM_PROVIDER=aws|anthropic|openai
LLM_CHOICE=claude-3-5-sonnet-20241022|gpt-4o|amazon.nova-lite-v1:0

# MCP Server Configuration  
OBSIDIAN_VAULT_PATH=/path/to/your/vault
SEARXNG_BASE_URL=http://localhost:8080
TODOIST_API_TOKEN=your_todoist_api_token
YOUTUBE_API_KEY=your_youtube_api_key

4.测试配置

# Test configuration and model setup
python main.py --config-test

5.运行应用程序

# CLI interface (interactive mode)
python main.py

# Single query mode
python main.py --query "Hello, can you introduce yourself?"

# Streamlit GUI interface (recommended)
python streamlit_gui.py

使用示例

代理使用Strands的原生多工具协调来完成复杂的任务:

研究和文件

"Research the latest developments in transformer architectures and create study notes"

代理使用: 网络搜索→ 笔记创建→ 可选任务创建

内容综合

"Find information about Strands Agents vs LangChain and create a comprehensive comparison"

代理使用: 多次搜索→ 使用比较格式创建笔记

视频分析

"Analyze this YouTube video about machine learning and create study materials"

代理使用: 视频处理→ 学习笔记创建

视觉辅助

"What's on my screen?" or "Can you see my screen?" or "Qu'est-ce que tu vois?"

代理使用: 屏幕截图→ 可视化分析→ 详细说明(适用于所有型号)

知识组织

"Search for MCP server documentation and organize it in my knowledge base"

代理使用: 搜索→ 保险库搜索→ 使用连接创建笔记

建筑

Strands代理实施

此项目已完全迁移到Strands Agents架构,提供:

  • 本地MCP集成:无缝的MCP服务器发现和工具注册
  • 多模型支持:在AWS Bedrock、Anthropic和OpenAI之间轻松切换
  • 流媒体响应:具有适当事件处理的实时响应流
  • 工具灵活性:简单 @tool 快速发展的装饰师
project/
├── agent/                  # Strands Agents implementation
│   ├── agent.py           # Main agent with native MCP integration
│   ├── tools.py           # Native tool implementations  
│   └── prompts.py         # System prompts and templates
├── tools/                  # Native tool implementations for optimal performance
│   └── obsidian/          # High-performance native Obsidian operations
│       ├── core.py        # CRUD operations (create, read, edit, delete)
│       ├── search.py      # Advanced search and tags functionality
│       ├── tags.py        # Tag management operations
│       └── utils.py       # Security and path validation utilities
├── config/                 # Configuration management
├── mcp_servers/            # MCP server configurations (SearXNG, Todoist, YouTube)
├── utils/                  # Shared utilities
│   ├── screen_capture.py  # Screenshot functionality with aspect ratio preservation
│   ├── bedrock_vision.py  # Direct Bedrock API for Nova models
│   ├── logger.py          # Langfuse integration
│   └── server_monitor.py  # Health monitoring
├── tests/                  # Comprehensive test suite
├── streamlit_gui.py        # Modern Streamlit interface
└── main.py                # CLI entry point

混合工具架构

本机工具(高性能):

  • 黑曜石:使用10个优化操作 @tool 装饰器
  • 视觉系统:截图捕获和分析
  • 屏幕信息:显示配置实用程序

MCP服务器(外部服务):

  • SearXNG:以隐私为重点的网络搜索
  • 简洁日程:任务管理和组织
  • 油管:视频分析和总结

Strands优势

模型灵活性:

  • 无缝提供商切换(AWS↔ Anthropic↔ OpenAI)
  • 特定于模型的优化(Nova direct API等)
  • 基于任务需求的动态模型选择

原生MCP支持:

  • 自动MCP服务器发现
  • 内置健康监测
  • 简化配置
  • 开发工具热重载

流媒体和性能:

  • 实时响应流
  • 本机事件处理
  • 持久代理会话
  • 优化工具执行

配置

LLM提供商

  • AWS基岩:为Amazon Nova、Claude和其他型号配置AWS凭据和区域
  • 人类直接:直接访问Claude API(不需要AWS帐户)
  • OpenAI:具有API密钥的GPT模型

工具配置

  1. 黑曜石(原生):设置 OBSIDIAN_VAULT_PATH 到您的保险库位置
  2. SearXNG(MCP):需要Docker-运行 docker-compose up -d 启动本地实例
  3. Todoist(MCP):添加Todoist API令牌
  4. YouTube(MCP):建议使用YouTube Data API v3密钥获取完整元数据

SearXNG设置

该项目包括为SearXNG预配置的Docker设置:

# Start SearXNG
docker-compose up -d

# Check if running
curl http://localhost:8080

# Stop SearXNG
docker-compose down

发展

测试

# Run all tests
pytest tests/

# Run specific test file
pytest tests/test_agent.py

# Test with verbose output
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=. --cov-report=html

代码质量

# Format code
black .

# Lint code
ruff check --fix .

# Type checking
mypy --ignore-missing-imports agent/ utils/ config/

开发命令

# Test configuration
python main.py --config-test

# Interactive CLI
python main.py

# Single query test
python main.py --query "test message"

# Streamlit GUI (development)
streamlit run streamlit_gui.py

工具集成

原生工具(Strands@tool)

  • 黑曜石:具有10个优化操作的Native Strands实现
    • 核心:创建、阅读、编辑、删除笔记
    • 高级:搜索、标签管理、批量操作
    • 性能:亚秒级响应时间,无MCP开销
  • 视觉:屏幕截图和多模型分析
  • 屏幕信息:显示配置和技术细节

MCP服务器(本地集成)

性能优化

为什么是Native vs MCP?

  • 本地工具:关键操作(笔记管理、视觉)直接使用Strands运行 @tool 装饰器
  • MCP服务器:外部服务受益于MCP的标准化和Strands的本地集成
  • 结果:在保持MCP生态系统效益的同时,为当地运营提供最佳性能

从PydanticAI迁移

该项目已成功从PydanticAI迁移到Strands Agent,实现了:

✅ 100%特征奇偶校验:保留所有功能
✅ 性能保持:运行速度无倒退
✅ 增强功能:原生MCP集成,更好的流媒体
✅ 简化架构:清洁剂 @tool 模式,更少样板
✅ 现代界面:带有实时流媒体的流式GUI

主要改进:

  • 本地MCP集成(无自定义解决方法)
  • 模型无关的架构,易于切换提供商
  • 实时流媒体响应
  • 简化工具开发 @tool 装饰器
  • 更好的错误处理和优雅的降级

许可证

MIT许可证