Files
fquiz/api
chengkai3 7ef266e4a0 feat:[FL-181][AI问答要支持function call]
实现AI问答的function call功能,支持调用系统接口进行查询。

改动内容:
1. 数据库扩展:
   - 在ai_chat_messages表增加tool_calls和tool_call_id字段
   - 创建数据库迁移文件

2. 模型和Schema更新:
   - AiChatMessage模型增加tool_calls(JSON)和tool_call_id字段
   - AiChatMessageSummary schema增加对应字段

3. Function Call实现:
   - 定义4个可调用函数:query_tower_models、query_lines、query_users、query_system_params
   - 实现_execute_function处理函数调用并返回格式化结果
   - 更新_call_openai_api支持tools参数

4. 消息流程更新:
   - 重构send_message支持完整的function call流程
   - 流程:用户消息 -> AI请求function call -> 执行函数 -> AI基于结果回复

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-06-22 23:59:13 +08:00
..
2026-04-24 15:50:52 +08:00

API Service

FastAPI 后端服务,包含用户认证和 RBAC 权限控制。

核心能力

  • JWT Access Token(默认 8 小时)
  • Refresh SessionHttpOnly Cookie,默认 30 天,刷新轮换)
  • RBAC(用户-角色-权限)
  • 用户管理接口(需 user.manage

本地开发

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r api/requirements.txt
python -m uvicorn api.app.main:app --reload --host 0.0.0.0 --port 8000

主要接口

  • GET /health
  • GET /api/v1/ping
  • POST /api/v1/auth/register
  • POST /api/v1/auth/login
  • POST /api/v1/auth/refresh
  • POST /api/v1/auth/logout
  • GET /api/v1/auth/me
  • GET /api/v1/users