提交 b3540c26 authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 620daf75
......@@ -49,7 +49,7 @@
// return { messages, post, isLoading }
// }
import { isString } from 'lodash-es'
import { aiChat } from '../api'
export function useChat() {
const messages = ref([])
......@@ -60,9 +60,21 @@ export function useChat() {
const response = await aiChat(data)
const items = response.data.items || []
items
.filter(item => item.type === 'text' || item.type === 'html')
.filter(item => item.type !== 'flow')
.forEach(item => {
messages.value.push({ role: 'assistant', content: item.content, type: item.type })
let content = item.content || ''
if (item.type === 'text') {
content = content.replaceAll('\n', '<br/>')
}
if (!isString(content)) {
try {
content = JSON.stringify(content)
} catch (error) {
console.log(error)
}
}
console.log(content)
messages.value.push({ role: 'assistant', content, type: item.type })
})
} catch (error) {
isLoading.value = false
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论