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 () => {