Commit a4f652fa by 前端

流式频率

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