mirror of
http://112.124.100.131/ebiz-ai/ebiz-base-ai.git
synced 2025-12-07 01:46:48 +08:00
Merge remote-tracking branch 'origin/feature/changesheng' into feature/changesheng
# Conflicts: # src/views/AI-new/components/chat-new.vue
This commit is contained in:
@@ -56,54 +56,54 @@ import { audioToText, gwcsChat } from '@/api/generatedApi'
|
||||
|
||||
const MESSAGE_STATUS = {
|
||||
processing: 1,
|
||||
end: 0,
|
||||
end: 0
|
||||
}
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SvgIcon,
|
||||
SvgIcon
|
||||
},
|
||||
props: {
|
||||
messages: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
default: () => []
|
||||
},
|
||||
messageStatus: {
|
||||
type: String,
|
||||
default: 'stop',
|
||||
default: 'stop'
|
||||
},
|
||||
isDeep: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
default: false
|
||||
},
|
||||
isSearching: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
default: false
|
||||
},
|
||||
conversationId: {
|
||||
type: String,
|
||||
default: '',
|
||||
default: ''
|
||||
},
|
||||
productName: {
|
||||
type: String,
|
||||
default: '',
|
||||
default: ''
|
||||
},
|
||||
autoScrollEnabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
default: false
|
||||
},
|
||||
chatData: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
default: () => ({})
|
||||
},
|
||||
appType: {
|
||||
type: String,
|
||||
default: 'gwcsHelper',
|
||||
default: 'gwcsHelper'
|
||||
},
|
||||
action: {
|
||||
type: String,
|
||||
default: 'normal_chat',
|
||||
},
|
||||
default: 'normal_chat'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -124,7 +124,7 @@ export default {
|
||||
genMessage: null,
|
||||
messageInfo: {
|
||||
is_complete: false.toString(),
|
||||
information: '',
|
||||
information: ''
|
||||
},
|
||||
currentMessageID: '',
|
||||
// 打字机相关
|
||||
@@ -154,7 +154,7 @@ export default {
|
||||
this.genMessage.status = MESSAGE_STATUS.processing
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deepInternet() {
|
||||
@@ -178,7 +178,7 @@ export default {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true })
|
||||
this.mediaRecorder = new MediaRecorder(stream)
|
||||
this.audioChunks = []
|
||||
this.mediaRecorder.ondataavailable = (event) => {
|
||||
this.mediaRecorder.ondataavailable = event => {
|
||||
if (event.data.size > 0) {
|
||||
this.audioChunks.push(event.data)
|
||||
}
|
||||
@@ -222,17 +222,17 @@ export default {
|
||||
formData.append('appType', 'haslBigHelper')
|
||||
formData.append('user', 'chenyuda')
|
||||
audioToText(formData)
|
||||
.then((res) => {
|
||||
.then(res => {
|
||||
if (res) {
|
||||
resolve(res.content)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
axiosGetAiChat() {
|
||||
axiosGetAiChat(requestIndex = 1) {
|
||||
const abortController = new AbortController()
|
||||
this.requestSingle = abortController
|
||||
this.messageInfo.information = this.single ? this.messageInfo.information : this.newMessage
|
||||
@@ -259,7 +259,7 @@ export default {
|
||||
conversationId: this.conversationId,
|
||||
message: this.action === 'normal_chat' ? this.newMessage : JSON.stringify(this.messageInfo),
|
||||
user: 'gwcs-test',
|
||||
inputs: {},
|
||||
inputs: {}
|
||||
}
|
||||
|
||||
this.currentMessage = {
|
||||
@@ -271,7 +271,7 @@ export default {
|
||||
isThink: false,
|
||||
showThink: false,
|
||||
isLike: false,
|
||||
isDisLike: false,
|
||||
isDisLike: false
|
||||
}
|
||||
if (this.single) {
|
||||
// this.$set(this.messages, this.messages.length - 1, { ...this.currentMessage })
|
||||
@@ -291,13 +291,13 @@ export default {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
signal: abortController.signal,
|
||||
body: JSON.stringify(params),
|
||||
timeout: 60000,
|
||||
timeout: 60000
|
||||
})
|
||||
.then(async (res) => {
|
||||
await this.processStreamResponse(res, this.requestIndex)
|
||||
.then(async res => {
|
||||
await this.processStreamResponse(res, requestIndex)
|
||||
this.single = false
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
// debugger
|
||||
this.$emit('update:messageStatus', 'stop')
|
||||
})
|
||||
@@ -316,7 +316,7 @@ export default {
|
||||
if (done) break
|
||||
buffer += new TextDecoder().decode(value)
|
||||
const lines = buffer.split('\n')
|
||||
lines.slice(0, -1).forEach((line) => {
|
||||
lines.slice(0, -1).forEach(line => {
|
||||
const parsed = this.parseStreamLine(line)
|
||||
if (parsed) this.updateMessageContent(parsed, requestIndex)
|
||||
})
|
||||
@@ -348,8 +348,8 @@ export default {
|
||||
if (is_complete && is_complete[1] === 'true' && text && text[1].trim() === '') {
|
||||
this.requestSingle.abort()
|
||||
this.single = true
|
||||
this.axiosGetAiChat()
|
||||
this.requestIndex++
|
||||
this.axiosGetAiChat(2)
|
||||
|
||||
// this.typingQueue = []
|
||||
return null
|
||||
}
|
||||
@@ -392,7 +392,7 @@ export default {
|
||||
const chars = {
|
||||
answer: answer,
|
||||
isThink: isThink,
|
||||
message_id,
|
||||
message_id
|
||||
}
|
||||
|
||||
this.typingQueue.push(chars)
|
||||
@@ -410,13 +410,6 @@ export default {
|
||||
|
||||
// 取出一个完整文本块
|
||||
const chunk = this.typingQueue.shift()
|
||||
// if (chunk.message_id !== this.currentMessageID) {
|
||||
// console.log('message_id !== this.currentMessageID');
|
||||
// typeNextChar()
|
||||
// return
|
||||
// }
|
||||
// console.log(this.messages);
|
||||
|
||||
const chars = Array.from(chunk.answer)
|
||||
|
||||
const isThink = chunk.isThink
|
||||
@@ -474,8 +467,8 @@ export default {
|
||||
|
||||
cancelSend() {
|
||||
this.requestSingle.abort()
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user