Files
AIclinicalresearch/backend/DEPLOY_TO_SAE_FOR_WECHAT_MP.md
HaHafeng 96290d2f76 feat(aia): Implement Protocol Agent MVP with reusable Agent framework
Sprint 1-3 Completed (Backend + Frontend):

Backend (Sprint 1-2):
- Implement 5-layer Agent framework (Query->Planner->Executor->Tools->Reflection)
- Create agent_schema with 6 tables (agent_definitions, stages, prompts, sessions, traces, reflexion_rules)
- Create protocol_schema with 2 tables (protocol_contexts, protocol_generations)
- Implement Protocol Agent core services (Orchestrator, ContextService, PromptBuilder)
- Integrate LLM service adapter (DeepSeek/Qwen/GPT-5/Claude)
- 6 API endpoints with full authentication
- 10/10 API tests passed

Frontend (Sprint 3):
- Add Protocol Agent entry in AgentHub (indigo theme card)
- Implement ProtocolAgentPage with 3-column layout
- Collapsible sidebar (Gemini style, 48px <-> 280px)
- StatePanel with 5 stage cards (scientific_question, pico, study_design, sample_size, endpoints)
- ChatArea with sync button and action cards integration
- 100% prototype design restoration (608 lines CSS)
- Detailed endpoints structure: baseline, exposure, outcomes, confounders

Features:
- 5-stage dialogue flow for research protocol design
- Conversation-driven interaction with sync-to-protocol button
- Real-time context state management
- One-click protocol generation button (UI ready, backend pending)

Database:
- agent_schema: 6 tables for reusable Agent framework
- protocol_schema: 2 tables for Protocol Agent
- Seed data: 1 agent + 5 stages + 9 prompts + 4 reflexion rules

Code Stats:
- Backend: 13 files, 4338 lines
- Frontend: 14 files, 2071 lines
- Total: 27 files, 6409 lines

Status: MVP core functionality completed, pending frontend-backend integration testing

Next: Sprint 4 - One-click protocol generation + Word export
2026-01-24 17:29:24 +08:00

2.9 KiB
Raw Blame History

部署微信服务号到SAE快速指南

🎯 目标

将微信服务号回调服务部署到SAE生产环境使用域名iit.xunzhengyixue.com


📋 Step 1: 确认环境变量配置

编辑 backend/.env,确认以下配置存在:

# 微信服务号配置
WECHAT_MP_APP_ID=wx062568ff49e4570c
WECHAT_MP_APP_SECRET=c0d19435d1a1e948939c16d767ec0faf
WECHAT_MP_TOKEN=IitPatientWechat2026JanToken
WECHAT_MP_ENCODING_AES_KEY=VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v

📋 Step 2: 在SAE控制台配置环境变量

  1. 登录阿里云SAE控制台
  2. 进入应用管理 → 选择应用
  3. 配置管理 → 环境变量
  4. 添加以下环境变量
WECHAT_MP_APP_ID=wx062568ff49e4570c
WECHAT_MP_APP_SECRET=c0d19435d1a1e948939c16d767ec0faf
WECHAT_MP_TOKEN=IitPatientWechat2026JanToken
WECHAT_MP_ENCODING_AES_KEY=VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v
  1. 保存配置

📋 Step 3: 部署代码到SAE

cd D:\MyCursor\AIclinicalresearch\backend
.\deploy-to-sae.ps1

等待部署完成约5-10分钟


📋 Step 4: 验证部署

访问以下URL确认服务正常

https://iit.xunzhengyixue.com/api/v1/iit/health

期望返回

{
  "status": "ok",
  "module": "iit-manager",
  "version": "1.1.0"
}

📋 Step 5: 配置微信公众平台

  1. 登录微信公众平台https://mp.weixin.qq.com/
  2. 进入:设置与开发 → 基本配置 → 服务器配置
  3. 点击"修改配置"
  4. 填写以下信息
配置项
URL https://iit.xunzhengyixue.com/wechat/patient/callback
Token IitPatientWechat2026JanToken
EncodingAESKey VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v
消息加解密方式 安全模式(推荐)
数据格式 XML
  1. 点击"提交"
  2. 验证成功后点击"启用"

验证成功标志

配置阶段:

  • 页面显示"配置成功"
  • 服务器配置状态为"已启用"

测试阶段:

  1. 关注公众号AI for 临床研究
  2. 查看SAE日志,应该看到:
📥 收到微信服务号回调消息
🔐 检测到加密消息,开始解密...
✅ 消息解密成功
👤 用户关注公众号

🔧 如何查看SAE日志

  1. 登录阿里云SAE控制台
  2. 应用管理 → 选择应用 → 实例管理
  3. 点击"日志" → "实时日志"
  4. 查看最近的日志输出

📝 优势

使用生产环境的优势:

  • 域名 iit.xunzhengyixue.com 已备案
  • HTTPS证书已配置
  • 已在企业微信中验证过
  • 无需natapp内网穿透
  • 稳定性更好
  • 无需配置域名验证

⏱️ 预计用时

  • 配置环境变量2分钟
  • 部署到SAE5-10分钟
  • 配置微信公众平台3分钟
  • 总计10-15分钟

立即开始部署! 🚀