提交 0bc38b77 编写于 作者: View Design's avatar View Design

Merge branch 'main' of gitcode.com:git_bot/ai-fe

......@@ -76,7 +76,8 @@ function initSearchItemInfo (info, records) {
}
function initSearchRecords (records) {
data.value = records.map(item => {
let { answer, actions, question } = item
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
......@@ -191,11 +192,11 @@ function handleFormatWebSource (source) {
return sources
}
function handleFormatReports (content) {
let chartStart = '::ProseLineChart'
let chartStart = '::ProseChart'
// todo
let tableStart = '::ProseDataTable'
let result = ''
// ::ProseLineChart{title='xxx' :labels='[]' :data='[]'}
// ::ProseLineChart{title='langchain-ai/langchain [2023-06-05,2024-06-04] Star Data' :labels='["2023-06-05","2023-06-12"]' :data='[43071,44946]'}
content.forEach(item => {
const { title, data, format } = item
if (format === 'timeline') {
......@@ -205,7 +206,7 @@ function handleFormatReports (content) {
labels.push(child.date)
datas.push(child.stargazers)
})
result += `${chartStart}{title=${title} :labels=${JSON.stringify(labels)} :data=${JSON.stringify(datas)}}`
result += `${chartStart}{title='${title}' :labels='${JSON.stringify(labels)}' :data='${JSON.stringify(datas)}'}`
} else if ( format === 'table' ) {
result += `${tableStart}{:data=${JSON.stringify(data)}}`
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册