# WeChat Agent - Windows 微信客户端 AI 自动化 基于视觉 AI 的 Windows 微信客户端自动化系统,实现消息识别与自动回复。 ## 项目概述 本项目实现对 Windows 微信客户端的 AI 自动化控制: - **信息获取**:通过视觉识别获取聊天记录、用户信息、消息内容 - **自动回复**:基于规则/AI 判断自动发送消息 - **纯视觉方案**:不依赖微信 API,通过屏幕截图 + VLM 识别 + 自动操作 ## 技术架构 ``` 微信Windows客户端(截图) ↓ UIAutomation + 屏幕截图 ↓ 阿里云百炼 Qwen-VL 视觉理解 ↓ LLM 推理判断(Qwen Plus) ↓ UIAutomation 执行操作 ↓ 微信客户端(发送) ``` ## 核心模块 | 模块 | 说明 | |-----|------| | `vlm` | 视觉模型接口(阿里云百炼 Bailian) | | `wechat` | 微信客户端控制(UIAutomation) | | `core` | 核心引擎(消息捕获、回复判断) | | `agent` | AI Agent 逻辑 | | `ui` | 桌面 UI 界面(待实现) | | `config` | 配置管理 | ## 技术栈 - **语言**: Python 3.10+ - **视觉模型**: 阿里云百炼 Qwen-VL 系列 - **LLM**: 阿里云百炼 Qwen Plus 系列 - **Windows 控制**: UIAutomation (PyWinAuto) - **API**: OpenAI 兼容格式(阿里云百炼) ## 快速开始 ### 1. 获取阿里云百炼 API Key 1. 访问 [阿里云百炼控制台](https://bailian.console.aliyun.com/) 2. 开通大模型服务 3. 创建 API Key: https://bailian.console.aliyun.com/cn-beijing#/APIKey ### 2. 安装依赖 ```bash pip install -r requirements.txt ``` ### 3. 配置 ```bash cp config.example.yaml config.yaml # 编辑 config.yaml 填入 API 配置 ``` 或在环境变量中设置: ```bash export ALIBABA_CLOUD_API_KEY=your-api-key # 或 export DASHSCOPE_API_KEY=your-api-key ``` ### 4. 运行 ```bash # 模拟模式(不连接微信,用于测试) python src/main.py --mock --demo # 实际运行(需要微信客户端运行) python src/main.py ``` ## 阿里云百炼模型 ### VLM 视觉模型(用于截图识别) | 模型 | 说明 | 推荐场景 | |-----|------|---------| | `qwen-vl-latest` | 最新 VL 模型 | **推荐**,微信截图识别 | | `qwen-vl2-7b` | Qwen-VL2 7B | 轻量级场景 | | `qwen-vl2-72b` | Qwen-VL2 72B | 高精度场景 | | `qwen2-vl-72b-instruct` | Qwen2-VL 72B | 最新一代 | ### LLM 模型(用于生成回复) | 模型 | 说明 | 推荐场景 | |-----|------|---------| | `qwen-plus` | Qwen Plus | **推荐**,日常对话 | | `qwen-max` | Qwen Max | 高质量回复 | | `qwen-turbo` | Qwen Turbo | 快速响应 | 更多模型: https://bailian.console.aliyun.com/cn-beijing#/model-market ## MVP 功能 ### Phase 1(本期) - [x] 项目初始化 - [x] 阿里云百炼 VLM 集成 - [x] 阿里云百炼 LLM 集成 - [ ] 微信窗口识别 - [ ] 聊天记录截图识别 - [ ] 用户信息识别 - [ ] 关键词自动回复 - [ ] 定时轮询机制 ### Phase 2(后续) - [ ] 知识库集成(OpenViking) - [ ] 多账号管理 - [ ] 复杂对话上下文 ## 配置示例 ```yaml vlm: model_type: bailian api_base: https://dashscope.aliyuncs.com/compatible-mode/v1 api_key: "" # 从环境变量读取 model_name: qwen-vl-latest max_tokens: 2048 temperature: 0.7 llm: api_base: https://dashscope.aliyuncs.com/compatible-mode/v1 api_key: "" model_name: qwen-plus max_tokens: 2048 temperature: 0.7 wechat: client_version: "3.8.x" poll_interval: 2.0 window_title: "微信" rules: - keywords: ["你好", "hi"] reply_type: keyword reply_content: "您好,有什么可以帮您的?" enabled: true ``` ## API 参考 ### 阿里云百炼 API - **基础 URL**: `https://dashscope.aliyuncs.com/compatible-mode/v1` - **认证**: `Authorization: Bearer {API_KEY}` - **格式**: OpenAI Chat Completions 兼容 ### VLM 核心方法 ```python from src.vlm.qwen_vl import BailianVLMClient, analyze_wechat_screenshot # 方式1: 直接分析微信截图 result = analyze_wechat_screenshot("wechat.png") # 方式2: 使用客户端 client = BailianVLMClient(api_key="your-key") result = client.analyze_chat_screenshot("wechat.png") ``` ## 参考项目 - [thiflow-research](http://192.168.5.5:3000/jesxion/thiflow-research) - Thiflow 产品研究 - [thiflow.com](https://thiflow.com/) - 参考产品 - [阿里云百炼](https://bailian.console.aliyun.com/) - VLM & LLM 提供商 ## License MIT