一键导入
api-overview
Fusion API 项目架构、技术栈、核心组件总览。Use when you need to understand how the backend works, its architecture, or tech stack.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Fusion API 项目架构、技术栈、核心组件总览。Use when you need to understand how the backend works, its architecture, or tech stack.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | api-overview |
| description | Fusion API 项目架构、技术栈、核心组件总览。Use when you need to understand how the backend works, its architecture, or tech stack. |
基于 FastAPI 的 AI 对话集成平台,通过 LiteLLM 提供统一的多 LLM 提供商接口。
API Layer (app/api/) ← FastAPI 路由
↓
Service Layer (app/services/) ← 业务逻辑
↓
AI Layer (app/ai/) ← LLMManager (LiteLLM)
↓
Data Layer (app/db/) ← SQLAlchemy ORM + Repository
app/ai/)llm_manager.py — LLM 调用管理器,PROVIDER_LITELLM_PREFIX 字典映射提供商
openrouter/ 前缀路由resolve_model() 根据 model_id 查凭证,构造 LiteLLM 参数tools.py — LLM Tool 定义(web_search)prompts/ — 提示词模板管理app/api/)chat.py — 对话(send/stop/stream-status/stream/conversations CRUD)files.py — 文件上传与管理models.py — 模型与凭证 CRUDauth.py — 用户认证app/services/)chat_service.py — 对话业务逻辑(传递 capabilities 给 stream_handler)stream_handler.py — Redis Stream 两段式流架构(核心),支持 web_search tool_call 检测stream_state_service.py — Redis Stream 状态管理(Lua 原子脚本)search_client.py — 搜索服务 HTTP 客户端(调用 search-service)memory_service.py — 数据库持久化task_manager.py — 后台任务注册与取消file_service.py — 文件处理app/core/)config.py — Pydantic Settingsredis.py — 连接池 + Lua 脚本加载security.py — JWT/JWKS 验证lua/ — Redis Lua 原子脚本app/db/models.py)POST /send
├─ create_task(generate_to_redis) # 后台任务,独立于 HTTP
│ └─ LLM chunk → XADD Redis Stream → 完成后写 PostgreSQL
└─ StreamingResponse(stream_redis_as_sse) # SSE 只读 Redis
└─ XREAD → 推送给客户端
客户端断线不影响生成,重连通过 GET /stream/{conv_id} 续读。
generate_to_redis() 后台任务
├─ 模型支持 functionCalling?
│ ├─ 否 → 纯流式路径(不变)
│ └─ 是 → 第一轮 LLM (stream=true, tools=[web_search])
│ ├─ delta.content → 正常输出(thinking 缓冲不推送)
│ └─ delta.tool_calls → 累积 → 调 search-service → 注入正文 → 第二轮流式
↓
落库 PostgreSQL (content: [ThinkingBlock?, SearchBlock?, TextBlock])
thinking_pending、search_start、search_complete 事件类型pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000 --reload # 开发
docker-compose up -d # Docker
pytest test/ # 测试
Add a new FastAPI API endpoint. Use when creating new REST API routes for the application.
Add a new LLM provider to fusion-api. Use when integrating a new AI model service.
Quick reference for all API endpoints. Use when you need to know available endpoints, their methods, and purposes.
Debug streaming issues (stop not working, content loss, reconnect problems). Use when SSE streaming has bugs.
查看 dev 服务器 fusion-api 日志。Use when debugging backend issues, checking errors, or tracing request flow.
用 curl 测试 dev 服务器 API 端点。Use to verify API behavior, test streaming, or debug issues end-to-end.