feat: 添加 conversation_id 以连续对话

This commit is contained in:
huangzhe
2025-07-30 16:42:14 +08:00
parent a99afd3982
commit 1e16ba0497

View File

@@ -115,6 +115,7 @@ export default {
isTyping: false,
typingSpeed: 30,
typingTimeout: null,
conversationId: ''
}
},
watch: {
@@ -223,7 +224,7 @@ export default {
this.currentMessage = JSON.parse(JSON.stringify(this.messageInfo))
let params = {
appType: "gwcsHelper",
conversationId: "",
conversationId: this.conversationId,
message: JSON.stringify(this.messageInfo),
user: "gwcs-test",
inputs: {},
@@ -242,7 +243,6 @@ export default {
if (this.single) {
this.messages.length -= 1
// deubg
this.messages.push(this.currentMessage)
} else {
this.messages.push(this.currentMessage)
@@ -302,10 +302,11 @@ export default {
},
parseStreamLine(line) {
try {
const cleanLine = line.replace(/^data:\s*/, '')
if (!cleanLine) return null
const data = JSON.parse(cleanLine)
// debugger/
this.conversationId = data.conversation_id
// console.log(data)
// console.log(data)
if (data.answer) {
@@ -314,14 +315,10 @@ export default {
const is_complete = /<is_complete>([^<]*)(?:<\/is_complete>)?/.exec(this.answerMap)
const information = /<information>([^<]*)(?:<\/information>)?/.exec(this.answerMap)
const text = /<text>([^<]*)(?:<\/text>)?/.exec(this.answerMap)
// console.log(`is_complete, information, text`, is_complete, information, text)
// const isCompleteRes = is_complete.some(item => item === 'true')
this.messageInfo.information = information ? information[1].trim() : this.newMessage
this.messageInfo.is_complete = is_complete ? is_complete[1].trim() : 'false'
if (is_complete && is_complete[1] === 'true' && text && text[1].trim() === '') {
// alert("message end")
this.requestSingle.abort()
// setTimeout(() => {