Commit Graph

3 Commits

Author SHA1 Message Date
chengkai3 5bf92a9ded feat:[FL-184][AI问答改成流式响应]
Co-authored-by: multica-agent <github@multica.ai>
2026-06-24 13:48:33 +08:00
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
chengkai3 21f9839dd6 feat: [FL-166] 实现AI问答功能
- 后端实现:
  - 添加 ai_chat_conversations 和 ai_chat_messages 数据模型
  - 创建 AI 问答 API 路由(/api/v1/ai-chat)
  - 实现对话管理和消息发送服务
  - 集成 OpenAI API 进行对话交互
  - 支持流式对话历史和上下文管理

- 前端实现:
  - 创建 ChatGPT 风格的聊天界面(/admin/ai-chat)
  - 支持新建、选择、删除对话
  - 实现消息发送和实时显示
  - 使用 Ant Design 组件构建响应式 UI

- 系统参数配置:
  - ai_chat.openai_api_key: OpenAI API 密钥
  - ai_chat.model: 使用的 AI 模型(默认 gpt-3.5-turbo)
  - ai_chat.base_url: API 基础 URL(支持第三方兼容接口)

- 数据库迁移:
  - 002_add_ai_chat.sql: 创建对话和消息表
  - 003_add_ai_chat_params.sql: 添加系统参数默认配置

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-06-20 23:20:26 +08:00