Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
salesgpt-project
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a4f652fa
authored
Mar 06, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
流式频率
1 parent
d33ba5f7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
51 deletions
src/mixins/socket.js
src/views/ai/car.vue
src/views/ai/chat.vue
src/mixins/socket.js
View file @
a4f652f
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-25 10:30:47
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-0
5 10:06:08
* @LastEditTime: 2024-03-0
6 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
},
3
0
)
},
5
0
)
this
.
toBottom
()
}
else
{
...
...
src/views/ai/car.vue
View file @
a4f652f
...
...
@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-02-23 09:47:18
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-03-0
5 10:45:25
* @LastEditTime: 2024-03-0
6 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
.
roleIndex
++
}
this
.
$set
(
this
.
descList
,
this
.
roleIndex
,
this
.
descList
[
this
.
roleIndex
]
+
msg
)
this
.
messageList
.
push
(
msg
)
if
(
!
this
.
timer
)
this
.
timer
=
setInterval
(()
=>
{
let
i
=
this
.
messageList
.
shift
()
if
(
i
==
'<rdfast stop>'
)
{
i
=
''
this
.
roleIndex
++
}
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
>
...
...
src/views/ai/chat.vue
View file @
a4f652f
...
...
@@ -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
:
{
...
...
@@ -94,10 +94,10 @@ export default {
return
{
type
:
AI_TYPE
.
sparring
,
tip_1
:
''
,
tip_2
:
''
,
tip_3
:
''
,
tip_2
:
''
,
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]]
...
...
@@ -132,46 +132,46 @@ export default {
jumpEvaluate
()
{
//收集历史记录
let
history
=
[]
this
.
contentList
.
forEach
((
item
,
index
)
=>
{
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
({
name
:
'ai.evaluate'
,
params
:
{
second
:
this
.
second
,
history
}
})
this
.
contentList
.
forEach
((
item
,
index
)
=>
{
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
({
name
:
'ai.evaluate'
,
params
:
{
second
:
this
.
second
,
history
}
})
},
setTips
(
msg
)
{
//流式输出提示语
this
.
tipList
.
push
(
msg
)
if
(
!
this
.
timer_t
)
this
.
timer_t
=
setInterval
(()
=>
{
this
.
isSend
=
false
let
i
=
this
.
tipList
.
shift
()
||
''
if
(
i
==
'<rdfast stop>'
)
{
i
=
''
this
.
tipIndex
++
}
this
[
`tip_
${
this
.
tipIndex
}
`
]
+=
i
if
(
this
.
tipList
.
length
==
0
&&
this
.
tipIndex
==
3
)
{
clearInterval
(
this
.
timer_t
)
this
.
timer_t
=
null
this
.
isSend
=
true
}
},
50
)
if
(
!
this
.
timer_t
)
this
.
timer_t
=
setInterval
(()
=>
{
this
.
isSend
=
false
let
i
=
this
.
tipList
.
shift
()
||
''
if
(
i
==
'<rdfast stop>'
)
{
i
=
''
this
.
tipIndex
++
}
this
[
`tip_
${
this
.
tipIndex
}
`
]
+=
i
if
(
this
.
tipList
.
length
==
0
&&
this
.
tipIndex
==
3
)
{
clearInterval
(
this
.
timer_t
)
this
.
timer_t
=
null
this
.
isSend
=
true
}
},
50
)
},
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
})
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment