From 11fe284316028b2abcea8d68bf08265b2205c598 Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Wed, 5 Jun 2024 16:45:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9searchweb=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/i/Create.vue | 12 +++++------- pages/search/[id].vue | 14 +++++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/components/i/Create.vue b/components/i/Create.vue index 0535cb3..632c938 100644 --- a/components/i/Create.vue +++ b/components/i/Create.vue @@ -97,13 +97,11 @@ const handleSearch = async () => { loading.value = true const currentRepo = $repos.value.find(item => item.label === selectedRepo.value) const repo_path = currentRepo ? currentRepo.url : '' - const { data, error } = await useRequest('/v1/chat/completion/create', { - method: 'post', - body: { - repo_path, - title: query.value - } - }) + const body = { + title: query.value, + repo_path: repo_path || '' + } + const { data, error } = await useRequest('/v1/chat/completion/create', { method: 'post', body }) loading.value = false if (error.value) return // todo 临时存到pina给搜索使用 diff --git a/pages/search/[id].vue b/pages/search/[id].vue index e07edf6..37a10a9 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -79,7 +79,6 @@ function initSearchRecords (records) { let { answer, actions, question, answer_type } = item answer = answer_type === 'json' ? handleFormatReports(answer) : answer const historyItem = { article: answer, question, desLoading: false, searchLoading: false, ansLoading: false, showActions: true} - // todo ?action为啥成了string? actions = typeof actions === 'string' ? JSON.parse(actions) : actions // 处理搜索过程 // todo 还有其他action @@ -91,6 +90,10 @@ function initSearchRecords (records) { historyItem.source = handleFormatSource(child.output) } else if (childAction === 'search_web') { historyItem.source = handleFormatWebSource(child.output) + } else if (childAction === 'tool_select') { + // todo + } else if (childAction === 'search_relate_repo') { + // todo } }) return historyItem @@ -262,13 +265,13 @@ function handleFormFetchData (fetchData) { Object.assign(askingData.value, { description: choices[0].message.content, desLoading: true }) break case 'search_file' : - const source = choices[0].message.content + let source = choices[0].message.content source = handleFormatSource(source) Object.assign(askingData.value, { desLoading: true, source, searchLoading: true, desLoading: false }) break case 'search_web' : - const sourceWeb = choices[0].message.content - source = handleFormatWebSource(sourceWeb) + let sourceWeb = choices[0].message.content + sourceWeb = handleFormatWebSource(sourceWeb) Object.assign(askingData.value, { desLoading: true, source: sourceWeb, searchLoading: true, desLoading: false }) break case 'tool_select' : @@ -315,6 +318,7 @@ function handleStopGenerate () { }) } function handleError (event) { + console.log(`error:`, event) askingData.value = {} handleStopGenerate() if (event) { @@ -333,7 +337,7 @@ async function fetchLinkedQuestion (query) { const { data } = await useRequest('/v1/chat/recomend_question', { method: 'post', body: { - repo_path: gitPath, + repo_path: gitPath || '', c_id: id, messages, // rephrase_question: true -- GitLab