|
@@ -39,7 +39,7 @@
|
|
|
| 目标服务 | 调用点 | 典型接口 | 用途 |
|
|
| 目标服务 | 调用点 | 典型接口 | 用途 |
|
|
|
|---|---|---|---|
|
|
|---|---|---|---|
|
|
|
| 4A Auth | [verify_external_token](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/utils/token.py#L175-L228) | `POST settings.auth.api_url` | 校验外部 token,解析 account 信息 |
|
|
| 4A Auth | [verify_external_token](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/utils/token.py#L175-L228) | `POST settings.auth.api_url` | 校验外部 token,解析 account 信息 |
|
|
|
-| 搜索服务(RAG) | [_rag_search](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/routers/chat.py#L529-L553) | `POST settings.search.api_url` | 向量检索/知识库检索,拼接上下文 |
|
|
|
|
|
|
|
+| AIChat 知识检索 | [_rag_search](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/routers/chat.py#L575-L609) | `POST {settings.aichat.api_url}/knowledge/search` | 通过 aichat 统一做向量检索/知识库检索,拼接上下文 |
|
|
|
| Qwen3(主模型) | [QwenService.chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L117-L207)、[QwenService.stream_chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L208-L256) | `POST {settings.qwen3.api_url}/v1/chat/completions` | 主问答生成与流式输出 |
|
|
| Qwen3(主模型) | [QwenService.chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L117-L207)、[QwenService.stream_chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L208-L256) | `POST {settings.qwen3.api_url}/v1/chat/completions` | 主问答生成与流式输出 |
|
|
|
| 意图识别模型 | [intent_recognition](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L73-L116) | `POST {settings.intent.api_url}/v1/chat/completions` | 识别 greeting/faq/知识库查询 等 |
|
|
| 意图识别模型 | [intent_recognition](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L73-L116) | `POST {settings.intent.api_url}/v1/chat/completions` | 识别 greeting/faq/知识库查询 等 |
|
|
|
| DeepSeek(备用模型) | [DeepSeekService.chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/deepseek_service.py#L24-L48)、[stream_chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/deepseek_service.py#L50-L89) | `POST {settings.deepseek.api_url}/v1/chat/completions` | Qwen3 失败时回退 |
|
|
| DeepSeek(备用模型) | [DeepSeekService.chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/deepseek_service.py#L24-L48)、[stream_chat](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/deepseek_service.py#L50-L89) | `POST {settings.deepseek.api_url}/v1/chat/completions` | Qwen3 失败时回退 |
|
|
@@ -102,7 +102,7 @@
|
|
|
- 写入 `AIMessage(type=ai, content='')` 占位
|
|
- 写入 `AIMessage(type=ai, content='')` 占位
|
|
|
- SSE 推送 `initial`(返回会话/消息 ID)
|
|
- SSE 推送 `initial`(返回会话/消息 ID)
|
|
|
4. 触发 RAG:
|
|
4. 触发 RAG:
|
|
|
- - `POST settings.search.api_url`,请求体 `{"query": message, "n_results": top_k}`
|
|
|
|
|
|
|
+ - `POST {settings.aichat.api_url}/knowledge/search`,请求体 `{"query_str": message, "n": top_k}`
|
|
|
- 将结果拼成 `rag_context`
|
|
- 将结果拼成 `rag_context`
|
|
|
5. 拼装 Prompt:
|
|
5. 拼装 Prompt:
|
|
|
- `final_answer`(含 userMessage、rag_context、historyContext、可选 online_search_content)
|
|
- `final_answer`(含 userMessage、rag_context、historyContext、可选 online_search_content)
|
|
@@ -127,7 +127,7 @@ sequenceDiagram
|
|
|
participant AU as 4A Auth
|
|
participant AU as 4A Auth
|
|
|
participant RT as chat.py:/stream/chat-with-db
|
|
participant RT as chat.py:/stream/chat-with-db
|
|
|
participant DB as MySQL
|
|
participant DB as MySQL
|
|
|
- participant SS as 搜索服务
|
|
|
|
|
|
|
+ participant AS as AIChat知识检索
|
|
|
participant QW as Qwen3
|
|
participant QW as Qwen3
|
|
|
participant DS as DeepSeek(回退)
|
|
participant DS as DeepSeek(回退)
|
|
|
|
|
|
|
@@ -141,8 +141,8 @@ sequenceDiagram
|
|
|
RT->>DB: insert ai placeholder AIMessage
|
|
RT->>DB: insert ai placeholder AIMessage
|
|
|
RT-->>FE: SSE data: {"type":"initial",...}
|
|
RT-->>FE: SSE data: {"type":"initial",...}
|
|
|
|
|
|
|
|
- RT->>SS: POST settings.search.api_url
|
|
|
|
|
- SS-->>RT: docs
|
|
|
|
|
|
|
+ RT->>AS: POST {settings.aichat.api_url}/knowledge/search
|
|
|
|
|
+ AS-->>RT: docs
|
|
|
RT->>QW: POST /v1/chat/completions (stream=true)
|
|
RT->>QW: POST /v1/chat/completions (stream=true)
|
|
|
alt Qwen3 失败
|
|
alt Qwen3 失败
|
|
|
RT->>DS: POST /v1/chat/completions (stream=true)
|
|
RT->>DS: POST /v1/chat/completions (stream=true)
|
|
@@ -171,7 +171,7 @@ sequenceDiagram
|
|
|
- 调用 [QwenService.intent_recognition](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L73-L116)
|
|
- 调用 [QwenService.intent_recognition](file:///Users/fanhong/UGIT/shudao-main/shudao-chat-py/services/qwen_service.py#L73-L116)
|
|
|
- 出站:`POST {settings.intent.api_url}/v1/chat/completions`
|
|
- 出站:`POST {settings.intent.api_url}/v1/chat/completions`
|
|
|
5. 若意图命中“知识库查询/技术咨询”,触发 RAG:
|
|
5. 若意图命中“知识库查询/技术咨询”,触发 RAG:
|
|
|
- - `POST settings.search.api_url`
|
|
|
|
|
|
|
+ - `POST {settings.aichat.api_url}/knowledge/search`
|
|
|
6. 组装 `final_answer` Prompt
|
|
6. 组装 `final_answer` Prompt
|
|
|
7. 非流式生成:
|
|
7. 非流式生成:
|
|
|
- `POST {settings.qwen3.api_url}/v1/chat/completions`(`stream=false`)
|
|
- `POST {settings.qwen3.api_url}/v1/chat/completions`(`stream=false`)
|
|
@@ -187,7 +187,7 @@ sequenceDiagram
|
|
|
participant MW as 中间件
|
|
participant MW as 中间件
|
|
|
participant RT as chat.py:/send_deepseek_message
|
|
participant RT as chat.py:/send_deepseek_message
|
|
|
participant IM as Intent模型
|
|
participant IM as Intent模型
|
|
|
- participant SS as 搜索服务
|
|
|
|
|
|
|
+ participant AS as AIChat知识检索
|
|
|
participant QW as Qwen3
|
|
participant QW as Qwen3
|
|
|
participant DS as DeepSeek(回退)
|
|
participant DS as DeepSeek(回退)
|
|
|
participant DB as MySQL
|
|
participant DB as MySQL
|
|
@@ -198,8 +198,8 @@ sequenceDiagram
|
|
|
RT->>IM: POST intent /v1/chat/completions
|
|
RT->>IM: POST intent /v1/chat/completions
|
|
|
IM-->>RT: intent_type
|
|
IM-->>RT: intent_type
|
|
|
opt 命中知识库查询
|
|
opt 命中知识库查询
|
|
|
- RT->>SS: POST settings.search.api_url
|
|
|
|
|
- SS-->>RT: docs
|
|
|
|
|
|
|
+ RT->>AS: POST {settings.aichat.api_url}/knowledge/search
|
|
|
|
|
+ AS-->>RT: docs
|
|
|
end
|
|
end
|
|
|
RT->>QW: POST qwen3 /v1/chat/completions (stream=false)
|
|
RT->>QW: POST qwen3 /v1/chat/completions (stream=false)
|
|
|
alt Qwen3 失败
|
|
alt Qwen3 失败
|
|
@@ -369,4 +369,3 @@ sequenceDiagram
|
|
|
- `deepseek.api_url`
|
|
- `deepseek.api_url`
|
|
|
- `dify.workflow_url` / `dify.workflow_id` / `dify.auth_token`
|
|
- `dify.workflow_url` / `dify.workflow_id` / `dify.auth_token`
|
|
|
- `aichat.api_url`
|
|
- `aichat.api_url`
|
|
|
-
|
|
|