提交 11fe2843 编写于 作者: D DebugIsFalse

fix: 兼容searchweb数据

上级 684fa20a
...@@ -97,13 +97,11 @@ const handleSearch = async () => { ...@@ -97,13 +97,11 @@ const handleSearch = async () => {
loading.value = true loading.value = true
const currentRepo = $repos.value.find(item => item.label === selectedRepo.value) const currentRepo = $repos.value.find(item => item.label === selectedRepo.value)
const repo_path = currentRepo ? currentRepo.url : '' const repo_path = currentRepo ? currentRepo.url : ''
const { data, error } = await useRequest('/v1/chat/completion/create', { const body = {
method: 'post', title: query.value,
body: { repo_path: repo_path || ''
repo_path, }
title: query.value const { data, error } = await useRequest('/v1/chat/completion/create', { method: 'post', body })
}
})
loading.value = false loading.value = false
if (error.value) return if (error.value) return
// todo 临时存到pina给搜索使用 // todo 临时存到pina给搜索使用
......
...@@ -79,7 +79,6 @@ function initSearchRecords (records) { ...@@ -79,7 +79,6 @@ function initSearchRecords (records) {
let { answer, actions, question, answer_type } = item let { answer, actions, question, answer_type } = item
answer = answer_type === 'json' ? handleFormatReports(answer) : answer answer = answer_type === 'json' ? handleFormatReports(answer) : answer
const historyItem = { article: answer, question, desLoading: false, searchLoading: false, ansLoading: false, showActions: true} const historyItem = { article: answer, question, desLoading: false, searchLoading: false, ansLoading: false, showActions: true}
// todo ?action为啥成了string?
actions = typeof actions === 'string' ? JSON.parse(actions) : actions actions = typeof actions === 'string' ? JSON.parse(actions) : actions
// 处理搜索过程 // 处理搜索过程
// todo 还有其他action // todo 还有其他action
...@@ -91,6 +90,10 @@ function initSearchRecords (records) { ...@@ -91,6 +90,10 @@ function initSearchRecords (records) {
historyItem.source = handleFormatSource(child.output) historyItem.source = handleFormatSource(child.output)
} else if (childAction === 'search_web') { } else if (childAction === 'search_web') {
historyItem.source = handleFormatWebSource(child.output) historyItem.source = handleFormatWebSource(child.output)
} else if (childAction === 'tool_select') {
// todo
} else if (childAction === 'search_relate_repo') {
// todo
} }
}) })
return historyItem return historyItem
...@@ -262,13 +265,13 @@ function handleFormFetchData (fetchData) { ...@@ -262,13 +265,13 @@ function handleFormFetchData (fetchData) {
Object.assign(askingData.value, { description: choices[0].message.content, desLoading: true }) Object.assign(askingData.value, { description: choices[0].message.content, desLoading: true })
break break
case 'search_file' : case 'search_file' :
const source = choices[0].message.content let source = choices[0].message.content
source = handleFormatSource(source) source = handleFormatSource(source)
Object.assign(askingData.value, { desLoading: true, source, searchLoading: true, desLoading: false }) Object.assign(askingData.value, { desLoading: true, source, searchLoading: true, desLoading: false })
break break
case 'search_web' : case 'search_web' :
const sourceWeb = choices[0].message.content let sourceWeb = choices[0].message.content
source = handleFormatWebSource(sourceWeb) sourceWeb = handleFormatWebSource(sourceWeb)
Object.assign(askingData.value, { desLoading: true, source: sourceWeb, searchLoading: true, desLoading: false }) Object.assign(askingData.value, { desLoading: true, source: sourceWeb, searchLoading: true, desLoading: false })
break break
case 'tool_select' : case 'tool_select' :
...@@ -315,6 +318,7 @@ function handleStopGenerate () { ...@@ -315,6 +318,7 @@ function handleStopGenerate () {
}) })
} }
function handleError (event) { function handleError (event) {
console.log(`error:`, event)
askingData.value = {} askingData.value = {}
handleStopGenerate() handleStopGenerate()
if (event) { if (event) {
...@@ -333,7 +337,7 @@ async function fetchLinkedQuestion (query) { ...@@ -333,7 +337,7 @@ async function fetchLinkedQuestion (query) {
const { data } = await useRequest('/v1/chat/recomend_question', { const { data } = await useRequest('/v1/chat/recomend_question', {
method: 'post', method: 'post',
body: { body: {
repo_path: gitPath, repo_path: gitPath || '',
c_id: id, c_id: id,
messages, messages,
// rephrase_question: true // rephrase_question: true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册