Commit a4f652fa by 前端

流式频率

1 parent d33ba5f7
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-25 10:30:47
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-05 10:06:08
* @LastEditTime: 2024-03-06 10:02:16
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\mixins\socket.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -88,7 +88,7 @@ export default {
this.timer_chat = null
}
this.contentList[len].content += i
}, 30)
}, 50)
this.toBottom()
} else {
......
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-23 09:47:18
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-05 10:45:25
* @LastEditTime: 2024-03-06 10:00:11
* @FilePath: \dj-scrm-wx-work-attachment-psd\src\views\ai\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -52,7 +52,9 @@ export default {
data() {
return {
isInput: false,
timer: null,
identityValue: '',
messageList: [],
roleIndex: -1,
desc_d: '',
descList: [],
......@@ -62,7 +64,7 @@ export default {
sceneList: CAR_SCENE,
identityList: [],
sceneIndex: 0,
identityIndex: 0,
identityIndex: 0
}
},
methods: {
......@@ -79,11 +81,20 @@ export default {
},
summarize(msg) {
if (this.roleIndex > -1) {
if (msg == '<rdfast stop>') {
msg = ''
this.messageList.push(msg)
if (!this.timer)
this.timer = setInterval(() => {
let i = this.messageList.shift()
if (i == '<rdfast stop>') {
i = ''
this.roleIndex++
}
this.$set(this.descList, this.roleIndex, this.descList[this.roleIndex] + msg)
if (this.messageList.length == 0) {
clearInterval(this.timer)
this.timer = null
}
this.$set(this.descList, this.roleIndex, this.descList[this.roleIndex] + i)
}, 50)
return
}
if (msg == '<rdfast stop>') {
......@@ -96,7 +107,7 @@ export default {
this.sendMessage(
JSON.stringify({
type: 'roles_generate_desc',
question: `你是一名购车客户你的身份是${this.identityList[i]},请根据你的身份从${CAR_TYPE}里面选一款车型,并描述你的用车意向,大约100字左右`,
question: `你是一名购车客户你的身份是${this.identityList[i]},请根据你的身份从${CAR_TYPE}里面选一款车型,并描述你的用车意向,大约100字左右`
// question: `你是一名购车客户你的身份是${this.identityList[i]},请根据你的身份描述你的用车意向,大约100字左右`
})
)
......@@ -120,15 +131,18 @@ export default {
this.identityIndex = item
},
handleSure() {
const index = CAR_TYPE.findIndex(i=>this.descList[this.identityIndex].includes(i))
const index = CAR_TYPE.findIndex(i => this.descList[this.identityIndex].includes(i))
this.$router.push({
path: 'chat',
query: {
identity: this.identityValue ? this.identityValue : this.identityList[this.identityIndex],
scene: index==-1?0:index
scene: index == -1 ? 0 : index
}
})
}
},
beforeDestroy() {
clearInterval(this.timer)
}
}
</script>
......
......@@ -84,7 +84,7 @@
<script type="text/ecmascript-6">
import Socket from '@/mixins/socket'
import AudioToWord from '@/mixins/AudioToWord'
import { CAR_TYPE, CAR_TYPE_DESC, CAR_TIPS, ROLE_LIST,AI_TYPE } from '@/utils/constants'
import { CAR_TYPE, CAR_TYPE_DESC, CAR_TIPS, ROLE_LIST, AI_TYPE } from '@/utils/constants'
export default {
mixins: [Socket, AudioToWord],
props: {
......@@ -95,9 +95,9 @@ export default {
type: AI_TYPE.sparring,
tip_1: '',
tip_2: '',
tip_3:'',
tip_3: '',
tipIndex: 1,
tipList:[],
tipList: [],
timer_t: null,
excercise: true,
title: '',
......@@ -123,7 +123,7 @@ export default {
//获取传值
const { type, scene, identity } = this.$route.query,
car_type = CAR_TYPE_DESC.find(item => item.includes(type))
this.car_tips = CAR_TIPS(identity,CAR_TYPE[scene])
this.car_tips = CAR_TIPS(identity, CAR_TYPE[scene])
// this.title = `${type}`
this.title = `AI的身份是${identity}购买的意向车型是${[CAR_TYPE[scene]]}`
// this.issuesList = TIP_LIST[CAR_TYPR[identity]]
......@@ -133,7 +133,7 @@ export default {
//收集历史记录
let history = []
this.contentList.forEach((item, index) => {
if(index%2==0)history.push({ role: ROLE_LIST.user, content: this.contentList[index].content })
if (index % 2 == 0) history.push({ role: ROLE_LIST.user, content: this.contentList[index].content })
else history.push({ role: ROLE_LIST.assistant, content: this.contentList[index].content })
})
this.$router.push({
......@@ -150,13 +150,13 @@ export default {
if (!this.timer_t)
this.timer_t = setInterval(() => {
this.isSend = false
let i = this.tipList.shift()||''
let i = this.tipList.shift() || ''
if (i == '<rdfast stop>') {
i = ''
this.tipIndex ++
this.tipIndex++
}
this[`tip_${this.tipIndex}`]+=i
if (this.tipList.length == 0&&this.tipIndex == 3) {
this[`tip_${this.tipIndex}`] += i
if (this.tipList.length == 0 && this.tipIndex == 3) {
clearInterval(this.timer_t)
this.timer_t = null
this.isSend = true
......@@ -166,12 +166,12 @@ export default {
getIssuesList() {
const history = []
if (this.contentList.length) {
for(let i=0;i< this.contentList.length;i++){
if(i%2==0)history.push({ role: ROLE_LIST.user, content: this.contentList[i].content })
for (let i = 0; i < this.contentList.length; i++) {
if (i % 2 == 0) history.push({ role: ROLE_LIST.user, content: this.contentList[i].content })
else history.push({ role: ROLE_LIST.assistant, content: this.contentList[i].content })
}
}
this.pushMsg(AI_TYPE.sparring_reply, history,this.contentList.at(-1).content)
this.pushMsg(AI_TYPE.sparring_reply, history, this.contentList.at(-1).content)
},
defaultFun() {
this.timer = setInterval(() => {
......@@ -197,16 +197,19 @@ export default {
if (!this.issue || !this.isSend) {
return
}
this.tipIndex = 1;
this.tipIndex = 1
this.tip_1 = ''
this.tip_2 = ''
let history = []
if (this.contentList.length) {
for(let i=0;i< this.contentList.length;i++){
if(i == 0) {
history.push({"role": ROLE_LIST.system,"content":"你需要扮演一个购车客户,模拟购车客户与我(销售人员)对话,你只能提问题,不要回答购车客户的问题。"},{ role: ROLE_LIST.system, content: this.car_tips })
for (let i = 0; i < this.contentList.length; i++) {
if (i == 0) {
history.push(
{ role: ROLE_LIST.system, content: '你需要扮演一个购车客户,模拟购车客户与我(销售人员)对话,你只能提问题,不要回答购车客户的问题。' },
{ role: ROLE_LIST.system, content: this.car_tips }
)
}
if(i%2==0)history.push({ role: ROLE_LIST.user, content: this.contentList[i].content })
if (i % 2 == 0) history.push({ role: ROLE_LIST.user, content: this.contentList[i].content })
else history.push({ role: ROLE_LIST.assistant, content: this.contentList[i].content })
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!