diff --git a/pages/search/[id].vue b/pages/search/[id].vue index 0f44a1d0fcdb00dcf1ad9780c995bfc11e779057..cc6fd54ab08fc0666ed25446f22df509098a34e1 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -190,6 +190,16 @@ function handleFormatWebSource (source) { } catch (error) {} return sources } +function handleFormatReports (content) { + let start = '::ProseLineChart' + let result = '' + content.forEach(item => { + const { title, data, columns } = item + let toStr = JSON.stringify({ title, data, columns }) + result += `${start}{:data=${toStr}}` + }) + return result +} function handleSetNoPermission () { askingData.value = {} useRequestError(403) @@ -213,29 +223,33 @@ function handleFormFetchData (fetchData) { handleStopGenerate() } if (meta.type === 'answer') { - Object.assign(askingData.value, { ansLoading: true, desLoading: false, searchLoading: false, article: message.choices[0].message.content, collapse: false }) + // todo 处理chart图表 + let article = message.choices[0].message.content + article = Array.isArray(article) ? handleFormatReports(article) : article + Object.assign(askingData.value, { ansLoading: true, desLoading: false, searchLoading: false, article, collapse: false }) return } if (meta.type !== 'log') return - - if (meta.action === 'rephrase_question') { - Object.assign(askingData.value, { description: choices[0].message.content, desLoading: true }) - resetAutoBottom() - return - } - if (meta.action === 'search_file') { - let source = choices[0].message.content - source = handleFormatSource(source) - Object.assign(askingData.value, { desLoading: true, source, searchLoading: true, desLoading: false }) - resetAutoBottom() - return - } - if (meta.action === 'search_web') { - let source = choices[0].message.content - source = handleFormatWebSource(source) - Object.assign(askingData.value, { desLoading: true, source, searchLoading: true, desLoading: false }) - resetAutoBottom() + switch (meta.action) { + case 'rephrase_question' : + Object.assign(askingData.value, { description: choices[0].message.content, desLoading: true }) + break + case 'search_file' : + const 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) + Object.assign(askingData.value, { desLoading: true, source: sourceWeb, searchLoading: true, desLoading: false }) + break + case 'tool_select' : + // todo 按需求做 + Object.assign(askingData.value, { toolsLoading: true }) + break } + resetAutoBottom() } function handleCreateAiTitle () { if (isFirstCreate) {