Files
AIclinicalresearch/backend/CLOSEAI-CONFIG.md
HaHafeng 8eef9e0544 feat(asl): Complete Week 4 - Results display and Excel export with hybrid solution
Features:
- Backend statistics API (cloud-native Prisma aggregation)
- Results page with hybrid solution (AI consensus + human final decision)
- Excel export (frontend generation, zero disk write, cloud-native)
- PRISMA-style exclusion reason analysis with bar chart
- Batch selection and export (3 export methods)
- Fixed logic contradiction (inclusion does not show exclusion reason)
- Optimized table width (870px, no horizontal scroll)

Components:
- Backend: screeningController.ts - add getProjectStatistics API
- Frontend: ScreeningResults.tsx - complete results page (hybrid solution)
- Frontend: excelExport.ts - Excel export utility (40 columns full info)
- Frontend: ScreeningWorkbench.tsx - add navigation button
- Utils: get-test-projects.mjs - quick test tool

Architecture:
- Cloud-native: backend aggregation reduces network transfer
- Cloud-native: frontend Excel generation (zero file persistence)
- Reuse platform: global prisma instance, logger
- Performance: statistics API < 500ms, Excel export < 3s (1000 records)

Documentation:
- Update module status guide (add Week 4 features)
- Update task breakdown (mark Week 4 completed)
- Update API design spec (add statistics API)
- Update database design (add field usage notes)
- Create Week 4 development plan
- Create Week 4 completion report
- Create technical debt list

Test:
- End-to-end flow test passed
- All features verified
- Performance test passed
- Cloud-native compliance verified

Ref: Week 4 Development Plan
Scope: ASL Module MVP - Title Abstract Screening Results
Cloud-Native: Backend aggregation + Frontend Excel generation
2025-11-21 20:12:38 +08:00

4.3 KiB
Raw Blame History

CloseAI配置更新指南

目标: 将CloseAI配置添加到 .env 文件
预计时间: 2分钟


🚀 方法一:自动更新(推荐)

backend 目录下运行PowerShell脚本

cd AIclinicalresearch\backend
.\update-env-closeai.ps1

脚本会自动将CloseAI配置添加到您的 .env 文件末尾。


✏️ 方法二:手动更新

如果自动脚本不可用,请手动更新:

步骤1打开 .env 文件

用文本编辑器VS Code、记事本等打开

AIclinicalresearch\backend\.env

步骤2在文件末尾添加以下内容

# ================================
# CloseAI配置代理OpenAI和Claude
# ================================
# CloseAI是一个API代理平台提供稳定的OpenAI和Claude访问
# 官网https://platform.openai-proxy.org

# 统一API Key同时用于OpenAI和Claude
CLOSEAI_API_KEY=sk-cu0iepbXYGGx2jc7BqP6ogtSWmP6fk918qV3RUdtGC3Edlpo

# OpenAI端点
CLOSEAI_OPENAI_BASE_URL=https://api.openai-proxy.org/v1

# Claude端点
CLOSEAI_CLAUDE_BASE_URL=https://api.openai-proxy.org/anthropic

# 支持的模型:
# - OpenAI: gpt-5-pro (最新), gpt-4-turbo-preview, gpt-3.5-turbo
# - Claude: claude-sonnet-4-5-20250929 (最新), claude-3-5-sonnet-20241022

步骤3保存文件

Ctrl+S 保存。

步骤4重启后端服务

# 停止当前服务Ctrl+C
# 重新启动
cd backend
npm run dev

验证配置

启动后端后,检查日志中是否有以下内容:

✓ CloseAI API Key已配置
✓ 可使用GPT-5-Pro和Claude-4.5-Sonnet

📝 完整的 .env 配置参考

如果您想查看完整的 .env 配置模板,请参考:

  • docs/07-运维文档/02-环境变量配置模板.md

🔧 配置说明

CLOSEAI_API_KEY

值: sk-cu0iepbXYGGx2jc7BqP6ogtSWmP6fk918qV3RUdtGC3Edlpo

  • 这是您的真实CloseAI API Key
  • 一个Key可同时调用OpenAI和Claude
  • 请妥善保管,不要泄露

CLOSEAI_OPENAI_BASE_URL

值: https://api.openai-proxy.org/v1

  • OpenAI API的代理端点
  • 兼容OpenAI SDK标准接口

CLOSEAI_CLAUDE_BASE_URL

值: https://api.openai-proxy.org/anthropic

  • Claude API的代理端点
  • 通过OpenAI SDK格式调用Claude

🎯 可用模型

添加配置后,您可以使用以下模型:

模型 Model ID 用途
GPT-5-Pro gpt-5-pro 最新OpenAI模型文献精准筛选
GPT-4-Turbo gpt-4-turbo-preview GPT-4高性能版本
Claude-4.5-Sonnet claude-sonnet-4-5-20250929 最新Claude模型第三方仲裁
Claude-3.5-Sonnet claude-3-5-sonnet-20241022 Claude稳定版本

💡 测试配置

配置完成后,可以使用以下代码测试:

// backend/test-closeai.ts
import OpenAI from 'openai';

// 测试GPT-5
const gpt5Client = new OpenAI({
  apiKey: 'sk-cu0iepbXYGGx2jc7BqP6ogtSWmP6fk918qV3RUdtGC3Edlpo',
  baseURL: 'https://api.openai-proxy.org/v1',
});

const gpt5Response = await gpt5Client.chat.completions.create({
  model: 'gpt-5-pro',
  messages: [{ role: 'user', content: '你好,请简单介绍一下自己' }],
});

console.log('GPT-5:', gpt5Response.choices[0].message.content);

// 测试Claude-4.5
const claudeClient = new OpenAI({
  apiKey: 'sk-cu0iepbXYGGx2jc7BqP6ogtSWmP6fk918qV3RUdtGC3Edlpo',
  baseURL: 'https://api.openai-proxy.org/anthropic',
});

const claudeResponse = await claudeClient.chat.completions.create({
  model: 'claude-sonnet-4-5-20250929',
  messages: [{ role: 'user', content: '你好,请简单介绍一下自己' }],
});

console.log('Claude-4.5:', claudeResponse.choices[0].message.content);

⚠️ 注意事项

  1. 不要提交到Git .env 文件已在 .gitignore 中,确保不会提交
  2. API Key安全 定期更换API Key避免泄露
  3. 成本监控: 定期检查CloseAI后台的使用量和费用

📚 相关文档


更新完成后您就可以在ASL模块中使用4个LLM了 🎉