From e1e5d4f30d1b0094365a4719ea03c63b444dce06 Mon Sep 17 00:00:00 2001 From: liuguancen Date: Tue, 7 Apr 2026 15:02:54 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=89=8D=E7=AB=AF+=E5=90=8E=E7=AB=AF+RAG]=20?= =?UTF-8?q?=E6=A3=80=E7=B4=A2=E8=8C=83=E5=9B=B4=E5=88=87=E6=8D=A2(?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=96=87=E4=BB=B6/=E6=95=B4=E4=B8=AA?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93)=EF=BC=9B=E8=81=94=E7=BD=91?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD(SearXNG)=EF=BC=9B=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=BB=93=E6=9E=9C=E5=B8=A6=E7=BD=91=E7=BB=9C=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=EF=BC=9B=E4=BF=AE=E5=A4=8DRAG=E6=A3=80=E7=B4=A2source?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=B8=8D=E5=8C=B9=E9=85=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/gpt/SmartChatController.java | 1 + .../chat/gpt/pojo/dto/SmartChatQueryDto.java | 3 + .../chat/gpt/pojo/dto/SmartChatSelfDto.java | 6 +- .../src/components/ReadingCreate.vue | 119 +++++++++++++++--- langchain-chat/server/chat/ZhipuSearchAPI.py | 5 +- langchain-chat/server/chat/self_kb_chat.py | 60 ++++++--- 6 files changed, 158 insertions(+), 36 deletions(-) diff --git a/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/controller/gpt/SmartChatController.java b/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/controller/gpt/SmartChatController.java index f611435..4c9756e 100644 --- a/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/controller/gpt/SmartChatController.java +++ b/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/controller/gpt/SmartChatController.java @@ -247,6 +247,7 @@ public class SmartChatController extends BaseController { } talkDto.setKnowledgeBaseNameList(knowledgeBaseNameList); + talkDto.setWebSearch(smartChatQueryDto.getWebSearch()); talkDto.setQuery(chatMessages.getContent().replaceAll("\n", "")); talkDto.setStream(true); diff --git a/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatQueryDto.java b/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatQueryDto.java index e6f222a..0673066 100644 --- a/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatQueryDto.java +++ b/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatQueryDto.java @@ -35,4 +35,7 @@ public class SmartChatQueryDto { /* 用户请求类型 **/ private Integer chatType; + /* 是否开启联网搜索 **/ + private Boolean webSearch; + } diff --git a/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatSelfDto.java b/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatSelfDto.java index bd893c2..4568dfc 100644 --- a/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatSelfDto.java +++ b/chat_web_backend/src/main/java/com/inspur/llm/chat/gpt/pojo/dto/SmartChatSelfDto.java @@ -46,6 +46,10 @@ public class SmartChatSelfDto { /* 用户请求类型 **/ private Integer chatType; + /* 是否开启联网搜索 **/ + @JsonProperty("web_search") + private Boolean webSearch; + public String toJsonString() { StringBuffer str = new StringBuffer(); extracted(knowledgeBaseNameList, str); @@ -63,7 +67,7 @@ public class SmartChatSelfDto { ", \"fileNames\":" + fileNameList + ", \"quote\":\"" + ReplaceUtils.replaceHiddenChars(quote) + '\"' + ", \"prompt_name\":\"" + promptName + '\"' + -// ", \"use_model_self_response\":\"" + "False" + '\"' + + ", \"web_search\":" + (webSearch != null && webSearch ? "true" : "false") + '}'; } diff --git a/chat_web_front/src/components/ReadingCreate.vue b/chat_web_front/src/components/ReadingCreate.vue index 5be0c74..39116d7 100644 --- a/chat_web_front/src/components/ReadingCreate.vue +++ b/chat_web_front/src/components/ReadingCreate.vue @@ -9,16 +9,27 @@
-
- -
+
清除对话
+
+
检索范围:
+
+ 📄 + {{ selectedFile.fileName }} +
+
+ 📁 + {{ selectedFile.folderName }} +
+
+
@@ -34,10 +45,17 @@ @input="handleInput" @keydown.enter="keyDown" placeholder="请输入你想提的问题,字数不能超过1000字"/> -
- - - +
+
+ 🌐 + 联网搜索 +
+
+ + + +
@@ -76,6 +94,8 @@ const clearQuote = () => { } //const title = inject('aiboxTitle'); +const searchScope = ref<'file' | 'kb'>('file'); +const webSearchEnabled = ref(false); const textarea = ref(""); const firstChat = ref(true); const sendStatus = ref(false); @@ -198,12 +218,13 @@ const getFetchChatAPIProcess = async (type: string) => { headers: headers, signal: controller.signal, body: JSON.stringify({ - fileNames: [selectedFile.value?.embeddingId], + fileNames: searchScope.value === 'file' ? [selectedFile.value?.embeddingId] : [], conversationId: conversationId.value, promptName: "default", knowledgeBaseIdList: [selectedFile.value?.folderId], chatType: type, - quote: quoteMsg.value + quote: quoteMsg.value, + webSearch: webSearchEnabled.value }), } ); @@ -372,6 +393,7 @@ const loadChatHistory = async () => { // 监听文件切换,重新加载对话历史 watch(() => selectedFile.value?.fileId, () => { + searchScope.value = 'file'; loadChatHistory(); }); @@ -434,7 +456,7 @@ const handleStop = async () => {