diff --git a/components/i/Create.vue b/components/i/Create.vue index 0535cb38845fb5a2d41ba1278b0286e5b5f110dd..632c938538d131f18275ec913799bba803acaeb0 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 e07edf60cb762f5eb4ffd6470f917f4ef507cadb..37a10a9edd9427a05f587303797625042a977575 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