mirror of
http://112.124.100.131/ebiz-ai/ebiz-base-ai.git
synced 2025-12-09 02:46:50 +08:00
feat: 添加 conversation_id 以连续对话
This commit is contained in:
@@ -115,6 +115,7 @@ export default {
|
|||||||
isTyping: false,
|
isTyping: false,
|
||||||
typingSpeed: 30,
|
typingSpeed: 30,
|
||||||
typingTimeout: null,
|
typingTimeout: null,
|
||||||
|
conversationId: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -223,7 +224,7 @@ export default {
|
|||||||
this.currentMessage = JSON.parse(JSON.stringify(this.messageInfo))
|
this.currentMessage = JSON.parse(JSON.stringify(this.messageInfo))
|
||||||
let params = {
|
let params = {
|
||||||
appType: "gwcsHelper",
|
appType: "gwcsHelper",
|
||||||
conversationId: "",
|
conversationId: this.conversationId,
|
||||||
message: JSON.stringify(this.messageInfo),
|
message: JSON.stringify(this.messageInfo),
|
||||||
user: "gwcs-test",
|
user: "gwcs-test",
|
||||||
inputs: {},
|
inputs: {},
|
||||||
@@ -242,7 +243,6 @@ export default {
|
|||||||
|
|
||||||
if (this.single) {
|
if (this.single) {
|
||||||
this.messages.length -= 1
|
this.messages.length -= 1
|
||||||
// deubg
|
|
||||||
this.messages.push(this.currentMessage)
|
this.messages.push(this.currentMessage)
|
||||||
} else {
|
} else {
|
||||||
this.messages.push(this.currentMessage)
|
this.messages.push(this.currentMessage)
|
||||||
@@ -302,10 +302,11 @@ export default {
|
|||||||
},
|
},
|
||||||
parseStreamLine(line) {
|
parseStreamLine(line) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const cleanLine = line.replace(/^data:\s*/, '')
|
const cleanLine = line.replace(/^data:\s*/, '')
|
||||||
if (!cleanLine) return null
|
if (!cleanLine) return null
|
||||||
const data = JSON.parse(cleanLine)
|
const data = JSON.parse(cleanLine)
|
||||||
|
// debugger/
|
||||||
|
this.conversationId = data.conversation_id
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
if (data.answer) {
|
if (data.answer) {
|
||||||
@@ -314,14 +315,10 @@ export default {
|
|||||||
const is_complete = /<is_complete>([^<]*)(?:<\/is_complete>)?/.exec(this.answerMap)
|
const is_complete = /<is_complete>([^<]*)(?:<\/is_complete>)?/.exec(this.answerMap)
|
||||||
const information = /<information>([^<]*)(?:<\/information>)?/.exec(this.answerMap)
|
const information = /<information>([^<]*)(?:<\/information>)?/.exec(this.answerMap)
|
||||||
const text = /<text>([^<]*)(?:<\/text>)?/.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.information = information ? information[1].trim() : this.newMessage
|
||||||
this.messageInfo.is_complete = is_complete ? is_complete[1].trim() : 'false'
|
this.messageInfo.is_complete = is_complete ? is_complete[1].trim() : 'false'
|
||||||
if (is_complete && is_complete[1] === 'true' && text && text[1].trim() === '') {
|
if (is_complete && is_complete[1] === 'true' && text && text[1].trim() === '') {
|
||||||
// alert("message end")
|
|
||||||
|
|
||||||
this.requestSingle.abort()
|
this.requestSingle.abort()
|
||||||
// setTimeout(() => {
|
// setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user