feat: 实时对话的报告
This commit is contained in:
@@ -146,6 +146,7 @@
|
|||||||
id: messageList.value.length + 1,
|
id: messageList.value.length + 1,
|
||||||
text: '',
|
text: '',
|
||||||
isUser: false,
|
isUser: false,
|
||||||
|
sessionId: 'projectStore.state.id',
|
||||||
loading: true,
|
loading: true,
|
||||||
thinking: false,
|
thinking: false,
|
||||||
thinkingText: '',
|
thinkingText: '',
|
||||||
@@ -214,7 +215,8 @@
|
|||||||
if (!reader) throw new Error('无法获取流读取器')
|
if (!reader) throw new Error('无法获取流读取器')
|
||||||
|
|
||||||
const decoder = new TextDecoder()
|
const decoder = new TextDecoder()
|
||||||
|
let previousEventName = '' // 记录上一个事件名称
|
||||||
|
let hasReportStarted = false // 标记 report 是否已经开始
|
||||||
try {
|
try {
|
||||||
let flag = true
|
let flag = true
|
||||||
while (flag) {
|
while (flag) {
|
||||||
@@ -234,9 +236,6 @@
|
|||||||
let events = buffer.split(/\n\n/)
|
let events = buffer.split(/\n\n/)
|
||||||
buffer = events.pop() // 保留不完整块
|
buffer = events.pop() // 保留不完整块
|
||||||
|
|
||||||
let previousEventName = '' // 记录上一个事件名称
|
|
||||||
let hasReportStarted = false // 标记 report 是否已经开始
|
|
||||||
|
|
||||||
for (let event of events) {
|
for (let event of events) {
|
||||||
if (!event.trim()) continue
|
if (!event.trim()) continue
|
||||||
|
|
||||||
@@ -262,7 +261,10 @@
|
|||||||
reportsContent.value
|
reportsContent.value
|
||||||
) {
|
) {
|
||||||
isGeneratingReport.value = false
|
isGeneratingReport.value = false
|
||||||
localStorage.setItem('reportsContent', reportsContent.value)
|
localStorage.setItem(
|
||||||
|
'reportsContent_' + projectStore.state.id,
|
||||||
|
reportsContent.value
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
previousEventName = eventName
|
previousEventName = eventName
|
||||||
@@ -323,7 +325,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (eventName === 'report') {
|
if (eventName === 'report') {
|
||||||
reportsContent.value += jsonData.content
|
reportsContent.value += jsonData.report
|
||||||
} else {
|
} else {
|
||||||
if (jsonData.reasoning) {
|
if (jsonData.reasoning) {
|
||||||
aiMessage.thinking = true
|
aiMessage.thinking = true
|
||||||
|
|||||||
Reference in New Issue
Block a user