From db5013216725efe0a6de2d4a46d134c39e957849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E4=BA=AE?= <1271446412@qq.com> Date: Tue, 14 Jan 2025 08:06:56 +0000 Subject: [PATCH] support depth search --- src/api/controllers/chat.ts | 8 ++++++-- src/api/routes/chat.ts | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/api/controllers/chat.ts b/src/api/controllers/chat.ts index fe16aff..e09dbfb 100644 --- a/src/api/controllers/chat.ts +++ b/src/api/controllers/chat.ts @@ -80,6 +80,7 @@ async function removeConversation(convId: string, ticket: string) { async function createCompletion( model = MODEL_NAME, messages: any[], + searchType: string = '', ticket: string, refConvId = '', retryCount = 0 @@ -129,7 +130,8 @@ async function createCompletion( sessionType: "text_chat", parentMsgId, params: { - "fileUploadBatchId": util.uuid() + "fileUploadBatchId": util.uuid(), + "searchType": searchType, }, contents: messagesPrepare(messages, refs, !!refConvId), }) @@ -173,6 +175,7 @@ async function createCompletion( async function createCompletionStream( model = MODEL_NAME, messages: any[], + searchType: string = '', ticket: string, refConvId = '', retryCount = 0 @@ -220,7 +223,8 @@ async function createCompletionStream( sessionType: "text_chat", parentMsgId, params: { - "fileUploadBatchId": util.uuid() + "fileUploadBatchId": util.uuid(), + "searchType": searchType, }, contents: messagesPrepare(messages, refs, !!refConvId), }) diff --git a/src/api/routes/chat.ts b/src/api/routes/chat.ts index ca12105..4a4c27a 100644 --- a/src/api/routes/chat.ts +++ b/src/api/routes/chat.ts @@ -17,11 +17,12 @@ export default { const tokens = chat.tokenSplit(request.headers.authorization); // 随机挑选一个ticket const token = _.sample(tokens); - const { model, conversation_id: convId, messages, stream } = request.body; + const { model, conversation_id: convId, messages, search_type, stream } = request.body; if (stream) { const stream = await chat.createCompletionStream( model, messages, + search_type, token, convId ); @@ -32,6 +33,7 @@ export default { return await chat.createCompletion( model, messages, + search_type, token, convId );