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 61234200
authored
Mar 01, 2024
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
交互优化
1 parent
5478756a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
243 additions
and
146 deletions
src/mixins/socket.js
src/utils/constants.js
src/views/ai/car.vue
src/views/ai/chat.vue
src/views/ai/evaluate.vue
src/views/ai/index.vue
src/views/ai/questions.vue
src/mixins/socket.js
View file @
6123420
...
@@ -2,15 +2,15 @@
...
@@ -2,15 +2,15 @@
* @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-02-2
7 15:38:16
* @LastEditTime: 2024-02-2
9 22:05:50
* @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
*/
*/
const
Q_NUM
=
9
const
Q_NUM
=
9
import
{
ROLE_LIST
,
AI_TYPE
}
from
'@/utils/constants'
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
isEnd
:
true
,
path
:
'ws://192.168.3.191:7864/ws/1'
,
path
:
'ws://192.168.3.191:7864/ws/1'
,
isSend
:
true
,
isSend
:
true
,
timer_chat
:
null
,
timer_chat
:
null
,
...
@@ -18,6 +18,7 @@ export default {
...
@@ -18,6 +18,7 @@ export default {
messageAll
:
[],
messageAll
:
[],
issue
:
''
,
issue
:
''
,
contentList
:
[],
contentList
:
[],
deleteArr
:
[],
socket
:
''
socket
:
''
}
}
},
},
...
@@ -49,32 +50,33 @@ export default {
...
@@ -49,32 +50,33 @@ export default {
getMessage
:
function
(
res
)
{
getMessage
:
function
(
res
)
{
let
msg
=
res
.
data
let
msg
=
res
.
data
if
(
msg
==
'<rdfast stop>'
)
{
if
(
msg
==
'<rdfast stop>'
)
{
this
.
isEnd
=
true
if
(
!
this
.
timer_tip
)
this
.
isSend
=
true
this
.
timer_tip
=
setInterval
(()
=>
{
if
(
this
.
getEvaluate
&&
this
.
contentList
.
length
==
Q_NUM
&&
!
this
.
timer_jump
)
{
if
(
this
.
type
==
AI_TYPE
.
sparring
&&
this
.
messageAll
.
length
==
0
)
{
this
.
timer_jump
=
setInterval
(()
=>
{
this
.
getIssuesList
()
if
(
this
.
messageAll
.
length
==
0
)
{
this
.
getEvaluate
()
clearInterval
(
this
.
timer_jump
)
this
.
timer_jump
=
null
}
}
},
300
)
if
(
this
.
messageAll
.
length
==
0
)
{
clearInterval
(
this
.
timer_tip
)
this
.
timer_tip
=
null
}
}
},
100
)
if
(
this
.
endFun
)
this
.
endFun
()
if
(
this
.
endFun
)
this
.
endFun
()
if
(
this
.
type
!=
AI_TYPE
.
sparring_reply
)
{
this
.
isSend
=
true
return
return
}
}
}
if
(
this
.
summarize
)
{
if
(
this
.
summarize
)
{
this
.
summarize
(
msg
)
this
.
summarize
(
msg
)
return
return
}
}
if
(
this
.
contentList
.
length
==
0
)
{
if
(
this
.
type
!=
AI_TYPE
.
sparring_reply
)
{
if
(
this
.
contentList
.
length
==
1
)
{
this
.
contentList
.
push
({
this
.
contentList
.
push
({
contentType
:
1
,
contentType
:
1
,
content
:
''
content
:
''
})
})
}
}
// const len = this.contentList.length - 1
// this.contentList[len].content += msg
this
.
messageAll
.
push
(
msg
)
this
.
messageAll
.
push
(
msg
)
if
(
!
this
.
timer_chat
)
if
(
!
this
.
timer_chat
)
this
.
timer_chat
=
setInterval
(()
=>
{
this
.
timer_chat
=
setInterval
(()
=>
{
...
@@ -88,6 +90,9 @@ export default {
...
@@ -88,6 +90,9 @@ export default {
},
30
)
},
30
)
this
.
toBottom
()
this
.
toBottom
()
}
else
{
this
.
setTips
(
msg
)
}
},
},
// 发送消息给被连接的服务端
// 发送消息给被连接的服务端
/**
/**
...
@@ -97,25 +102,46 @@ export default {
...
@@ -97,25 +102,46 @@ export default {
chat 表示问答
chat 表示问答
*/
*/
sendMessage
:
function
(
params
)
{
sendMessage
:
function
(
params
)
{
try
{
this
.
socket
.
send
(
params
)
this
.
socket
.
send
(
params
)
}
catch
(
error
)
{
console
.
log
(
'发送消息失败:'
,
error
)
this
.
init
()
}
},
},
pushMsg
(
type
,
history
)
{
pushMsg
(
type
,
history
,
question_d
=
''
)
{
if
(
type
!=
AI_TYPE
.
sparring_reply
)
this
.
contentList
.
push
({
this
.
contentList
.
push
({
contentType
:
2
,
contentType
:
2
,
content
:
this
.
issue
content
:
this
.
issue
})
})
let
len
=
this
.
contentList
.
length
,
let
question
=
this
.
issue
question
=
this
.
issue
//对练场景,定义好角色
if
(
len
==
Q_NUM
-
1
&&
type
==
'sparring'
)
{
if
(
type
==
AI_TYPE
.
sparring
)
{
question
+=
',在我回答后,接下来你做出简洁的总结性回复,并且回答内容必须包含“对练已结束”'
question
=
'销售人员:'
+
question
}
}
this
.
type
=
type
if
(
question_d
)
{
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
this
.
sendMessage
(
this
.
sendMessage
(
JSON
.
stringify
({
JSON
.
stringify
({
type
,
type
,
question
,
question
:
question_d
?
question_d
:
question
,
history
:
JSON
.
stringify
([
i
%
2
==
0
?
{
role
:
ROLE_LIST
.
system
,
content
:
'以女性的口吻回复'
}
:
{
role
:
ROLE_LIST
.
system
,
content
:
'以男性的口吻回复'
},
...
history
])
})
)
}
}
else
{
this
.
sendMessage
(
JSON
.
stringify
({
type
,
question
:
question_d
?
question_d
:
question
,
history
:
JSON
.
stringify
(
history
)
history
:
JSON
.
stringify
(
history
)
})
})
)
)
}
if
(
type
!=
AI_TYPE
.
sparring_reply
)
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
this
.
contentList
.
push
({
this
.
contentList
.
push
({
contentType
:
1
,
contentType
:
1
,
...
@@ -129,7 +155,6 @@ export default {
...
@@ -129,7 +155,6 @@ export default {
close
()
{
close
()
{
this
.
socket
.
close
()
// 关闭 websocket
this
.
socket
.
close
()
// 关闭 websocket
this
.
socket
.
onclose
=
function
(
e
)
{
this
.
socket
.
onclose
=
function
(
e
)
{
console
.
log
(
e
)
//监听关闭事件
console
.
log
(
'关闭'
)
console
.
log
(
'关闭'
)
}
}
},
},
...
...
src/utils/constants.js
View file @
6123420
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* @Author: limin
* @Author: limin
* @Date: 2021-06-15 14:41:02
* @Date: 2021-06-15 14:41:02
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2024-02-2
7 21:17:54
* @LastEditTime: 2024-02-2
9 16:34:09
*/
*/
export
const
STORE_USER_KEY
=
'STORE_USER_KEY'
export
const
STORE_USER_KEY
=
'STORE_USER_KEY'
export
const
CAR_TYPE
=
[
export
const
CAR_TYPE
=
[
...
@@ -13,7 +13,26 @@ export const CAR_TYPE = [
...
@@ -13,7 +13,26 @@ export const CAR_TYPE = [
{
type
:
'问界M9'
,
url
:
'https://youjia-image.cdn.bcebos.com/modelImage/2ef3a04eff07e2a441bb16c61f3ff531/17035819401703266694.jpg@!thumbnail'
}
{
type
:
'问界M9'
,
url
:
'https://youjia-image.cdn.bcebos.com/modelImage/2ef3a04eff07e2a441bb16c61f3ff531/17035819401703266694.jpg@!thumbnail'
}
]
]
export
const
CAR_SCENE
=
[
'日常代步'
,
'短途自驾'
,
'商务出行'
,
'货物搬运'
,
'长途旅行'
]
export
const
CAR_SCENE
=
[
'日常代步'
,
'短途自驾'
,
'商务出行'
,
'货物搬运'
,
'长途旅行'
]
export
const
CAR_IDENTITY
=
[
'有钱的小老板'
,
'上班族'
,
'退休大爷'
,
'全职太太'
,
'车迷学生'
]
export
const
CAR_IDENTITY
=
[
'职场高管'
,
'上班族'
,
'退休职工'
,
'全职太太'
,
'车迷学生'
]
export
const
CAR_TYPR
=
{
职场高管
:
'M9'
,
上班族
:
'M7'
,
退休职工
:
'M5'
,
全职太太
:
'M5'
,
车迷学生
:
'M5'
}
export
const
ROLE_LIST
=
{
user
:
'user'
,
system
:
'system'
,
assistant
:
'assistant'
}
export
const
AI_TYPE
=
{
chat
:
'chat'
,
sparring
:
'sparring'
,
sparring_reply
:
'sparring_reply'
,
summarize
:
'summarize'
}
// export const CAR_TYPE_SCENE = [
// export const CAR_TYPE_SCENE = [
// `{
// `{
// 意向车型:问界M7
// 意向车型:问界M7
...
@@ -102,15 +121,26 @@ export const CAR_TYPE_DESC = [
...
@@ -102,15 +121,26 @@ export const CAR_TYPE_DESC = [
综合油耗(L/100km):7.2
综合油耗(L/100km):7.2
}`
}`
]
]
export
const
CAR_TIPS
=
(
product
,
scene
,
identity
)
=>
{
export
const
CAR_TIPS
=
identity
=>
{
return
`
return
`
你需要扮演一个购车客户,模拟与4S店销售人员对话。对话风格尽量自然、简短,每次提问的信息点不超过2个。
你需要扮演一个购车客户你的身份是
${
identity
}
,模拟购车客户与我(销售人员)对话,你只能提问题,不要回答购车客户的问题。对话风格尽量自然、简短,每次提问的信息点不超过2个,不要因为我回答的字数少,你自己回答自己的问题。
你意向的车型是
注意:将你的回复输出内容中的"购车客户:"删除
${
product
}
4S店在售车型包括【
你购车用途是
${
scene
}
问界M5:{插电混动车型,2023年4月上市,可选后驱、四驱版,售价25万~30万,中型SUV,1.5T发动机,手自一体变速箱,纯电255公里,综合续航640公里,零百加速4.5秒,综合油耗6.1L/百公里,优惠促销中,有赠品,智能化高,有激光、毫米波雷达,配合摄像头,超声波融合感知系统,主动避让、智能泊车、高速辅助、跟车辅助、变道辅助等,能在高效工况下运转,油耗更低,行驶更安静;低速行驶时,动力更强劲。主打日常通勤用途,短途出行。
你的身份是
${
identity
}
。
问界M5竞品:[{特斯拉Model-Y,纯电,31w,价格略贵,造型相似,内饰偏简约,空间比问界M5小,只靠摄像头辅助驾驶},{岚图FREE,造型相似,价格略便宜,智能化略低}]
我们对销售人员的考核标准包括【客户购车计划、竞品、试驾、产品参数、销售积极性、客户抗拒应对】,请模拟对话时关注这些点。
}
每次只生成一句话,等销售人员回答后再发起下一轮对话,记住你是购车客户,当前时间是2024-02-27。现在开始提问。
问界M7:{插电混动四驱车型,2023年9月上市,可选5座、6座版,售价29万~38万,中大型SUV,1.5T发动机,手自一体变速箱,纯电230公里,综合续航1220公里,零百加速4.9秒,综合油耗7.1L/百公里,优惠促销中,有赠品,智能化高,有激光、毫米波雷达,配合摄像头,超声波融合感知系统,主动避让、智能泊车、高速辅助、跟车辅助、变道辅助等,兼顾动力与续航,适合上下班日常代步,长途驾驶也更省心,
问界M7竞品:[{理想L7,增程,42w,动力略强,驾驶舒适性略差,销量火爆},{大众途昂,燃油车,33w,驾驶体验较差,智能化较差}]
}
问界M9:{插电混动车型,2023年12月上市,可选Ultra、Max版,售价55万~60万,D级豪华SUV,2.0T发动机,手自一体变速箱,纯电220公里,综合续航1020公里,零百加速4.3秒,综合油耗7.5L/百公里,可赠保养,智能化高,有激光、毫米波雷达,配合摄像头,超声波融合感知系统,主动避让、智能泊车、高速辅助、跟车辅助、变道辅助等,星光数字矩阵交互系统,100英寸大屏幕,主打豪华商务、科技感、更为先进的驾驶乘坐体验。
问界M9竞品:[{理想L9,45w,增程,油耗7.8,续航650公里,智能化略低}]
}
】
我们对销售人员的考核标准包括【客户购车计划、竞品、试驾、产品参数、销售积极性、客户抗拒应对】,请模拟对话时关注这些点。
每次只生成一句话,等销售人员回答后再发起下一轮对话,记住你是购车客户,当前时间是2024-02-27。现在开始提问。
`
`
}
}
export
const
TIP_LIST
=
{
export
const
TIP_LIST
=
{
...
...
src/views/ai/car.vue
View file @
6123420
...
@@ -2,27 +2,32 @@
...
@@ -2,27 +2,32 @@
* @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-02-2
7 21:21:08
* @LastEditTime: 2024-02-2
9 11:15:25
* @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
-->
-->
<
template
>
<
template
>
<div
class=
"ai-container"
>
<div
class=
"ai-container"
>
<div
class=
"car-box"
>
<div
class=
"header-box"
>
<div
class=
"car-item"
@
click=
"handleSelectCar(item)"
v-for=
"(item, index) in carList"
:key=
"index"
>
<div
class=
"title"
>
场景
</div>
<div
class=
"car-img"
><img
:src=
"item.url"
/></div>
<div
class=
"title-sub"
>
AI需要扮演一个购车客户,模拟与4S店销售人员对话
</div>
<div
class=
"car-desc"
>
{{
item
.
type
}}
</div>
</div>
</div>
</div>
<van-popup
v-model=
"show"
position=
"bottom"
round
closeable
:style=
"
{ height: '350px' }">
<div
class=
"car-box"
>
<div
class=
"popup-header"
>
你选择的车型是
{{
selectCar
.
type
}}
</div>
<div
class=
"card-title"
>
AI的身份
</div>
<div
class=
"card-title"
>
用车场景
</div>
<div
class=
"card-box"
>
<div
class=
"card-box"
>
<div
:class=
"
{ 'card-item': true, checked:
sceneIndex == index }" @click="handleSelectScene(index)" v-for="(item, index) in scene
List" :key="index">
<div
:class=
"
{ 'card-item': true, checked:
identityIndex == index }" @click="handleSelectIdentity(index)" v-for="(item, index) in identity
List" :key="index">
<div
class=
"card-desc"
>
{{
item
}}
</div>
<div
class=
"card-desc"
>
{{
item
}}
</div>
</div>
</div>
</div>
</div>
<div
class=
"card-title"
>
你的身份
</div>
<div
class=
"popup-btn"
@
click=
"handleSure"
>
确认
</div>
<!--
<div
class=
"car-item"
@
click=
"handleSelectCar(item)"
v-for=
"(item, index) in carList"
:key=
"index"
>
<div
class=
"car-img"
><img
:src=
"item.url"
/></div>
<div
class=
"car-desc"
>
{{
item
.
type
}}
</div>
</div>
-->
</div>
<van-popup
v-model=
"show"
position=
"bottom"
round
closeable
:style=
"
{ height: '350px' }">
<div
class=
"popup-header"
>
选择身份
</div>
<div
class=
"card-title"
>
AI的身份
</div>
<div
class=
"card-box"
>
<div
class=
"card-box"
>
<div
:class=
"
{ 'card-item': true, checked: identityIndex == index }" @click="handleSelectIdentity(index)" v-for="(item, index) in identityList" :key="index">
<div
:class=
"
{ 'card-item': true, checked: identityIndex == index }" @click="handleSelectIdentity(index)" v-for="(item, index) in identityList" :key="index">
<div
class=
"card-desc"
>
{{
item
}}
</div>
<div
class=
"card-desc"
>
{{
item
}}
</div>
...
@@ -61,8 +66,6 @@ export default {
...
@@ -61,8 +66,6 @@ export default {
this
.
$router
.
push
({
this
.
$router
.
push
({
path
:
'chat'
,
path
:
'chat'
,
query
:
{
query
:
{
type
:
this
.
selectCar
.
type
,
scene
:
this
.
sceneList
[
this
.
sceneIndex
],
identity
:
this
.
identityList
[
this
.
identityIndex
]
identity
:
this
.
identityList
[
this
.
identityIndex
]
}
}
})
})
...
@@ -73,13 +76,26 @@ export default {
...
@@ -73,13 +76,26 @@ export default {
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.ai-container
{
.ai-container
{
width
:
100%
;
width
:
100%
;
padding
:
10px
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
.header-box
{
padding
:
10px
;
width
:
100%
;
line-height
:
24px
;
background
:
#3582ee
;
color
:
#fff
;
.title
{
font-size
:
16px
;
}
.title-sub
{
font-size
:
12px
;
}
}
}
}
.car-box
{
.car-box
{
display
:
grid
;
margin-top
:
40px
;
grid-template-columns
:
1
fr
1
fr
;
/* 一行两列 */
}
gap
:
10px
;
.card-title
{
padding-left
:
20px
;
}
}
.car-item
{
.car-item
{
.car-img
{
.car-img
{
...
@@ -95,18 +111,6 @@ export default {
...
@@ -95,18 +111,6 @@ export default {
color
:
#222222
;
color
:
#222222
;
}
}
}
}
.popup-header
{
text-align
:
center
;
font-size
:
15px
;
height
:
50px
;
line-height
:
40px
;
color
:
#111
;
}
.card-title
{
font-size
:
14px
;
color
:
#333333
;
padding-left
:
20px
;
}
.card-box
{
.card-box
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
1
fr
1
fr
1
fr
;
/* 一行两列 */
grid-template-columns
:
1
fr
1
fr
1
fr
;
/* 一行两列 */
...
@@ -141,7 +145,7 @@ export default {
...
@@ -141,7 +145,7 @@ export default {
width
:
320px
;
width
:
320px
;
height
:
40px
;
height
:
40px
;
line-height
:
40px
;
line-height
:
40px
;
margin
:
10
auto
;
margin
:
60px
auto
;
text-align
:
center
;
text-align
:
center
;
font-size
:
16px
;
font-size
:
16px
;
border-radius
:
21px
;
border-radius
:
21px
;
...
...
src/views/ai/chat.vue
View file @
6123420
...
@@ -2,11 +2,10 @@
...
@@ -2,11 +2,10 @@
<div
:class=
"['chat-gpt-box']"
>
<div
:class=
"['chat-gpt-box']"
>
<div
class=
"header-box"
>
<div
class=
"header-box"
>
<div
class=
"title"
>
{{
title
}}
</div>
<div
class=
"title"
>
{{
title
}}
</div>
<div
class=
"title-sub"
>
{{
subTitle
}}
</div>
</div>
</div>
<div
class=
"sum-btn"
@
click=
"jumpEvaluate"
>
结束并评价
</div>
<div
class=
"tips-info"
v-if=
"contentList.length == 0"
>
稍后我们将进行回答...
</div>
<div
class=
"tips-info"
v-if=
"contentList.length == 0"
>
稍后我们将进行回答...
</div>
<div
:class=
"['view',
{ 'show-tips': showTips
&&
issuesList.length
}]" ref="contentView">
<div
:class=
"['view',
{ 'show-tips': showTips }]" ref="contentView">
<template
v-for=
"(i, index) in contentList"
>
<template
v-for=
"(i, index) in contentList"
>
<div
:key=
"index"
>
<div
:key=
"index"
>
<template
v-if=
"i.contentType == 1"
>
<template
v-if=
"i.contentType == 1"
>
...
@@ -19,7 +18,9 @@
...
@@ -19,7 +18,9 @@
</div>
</div>
<div
class=
"content"
>
<div
class=
"content"
>
<template
v-if=
"!i.content"
>
<template
v-if=
"!i.content"
>
<van-loading
class=
"loading"
color=
"#3582EE"
/>
<span
class=
"dot"
></span>
<span
class=
"dot"
></span>
<span
class=
"dot"
></span>
</
template
>
</
template
>
<
template
v-else
>
<
template
v-else
>
{{
i
.
content
}}
{{
i
.
content
}}
...
@@ -36,19 +37,28 @@
...
@@ -36,19 +37,28 @@
</div>
</div>
</template>
</template>
</div>
</div>
<
template
v-if=
"showTips
&& issuesList.length
"
>
<
template
v-if=
"showTips"
>
<div
class=
"tips-box"
>
<div
class=
"tips-box"
>
<div
class=
"tips-title flex"
>
<div
class=
"tips-title flex"
>
您可以
这样
回答
您可以
选择下面的内容进行
回答
<div
class=
"sprite-icon icon-close"
@
click=
"showTips = false"
></div>
<div
class=
"sprite-icon icon-close"
@
click=
"showTips = false"
></div>
</div>
</div>
<div
class=
"tips-view"
>
<div
class=
"tips-view"
>
<template
v-for=
"(i, index) in issuesList"
>
<
!--
<
template
v-for=
"(i, index) in issuesList"
>
<div
:key=
"index"
class=
"tips-item flex"
@
click=
"send(i)
"
>
<div
class=
"tips-item flex"
@
click=
"send(i)"
:key=
"index
"
>
{{
i
}}
{{
i
}}
<div
class=
"sprite-icon icon-more"
></div>
<div
class=
"sprite-icon icon-more"
></div>
</div>
</div>
</
template
>
</
template
>
-->
<div
class=
"tips-item flex"
@
click=
"send(tip_1)"
>
{{ tip_1 ? tip_1 : '正在努力生成,请稍后...' }}
</div>
<div
class=
"tips-item flex"
v-if=
"tip_2"
@
click=
"send(tip_2)"
>
{{ tip_2 }}
</div>
<!-- <div class="tips-item flex" v-if="tip_3" @click="send(tip_3)">
{{ tip_3 }}
</div> -->
</div>
</div>
</div>
</div>
</template>
</template>
...
@@ -71,14 +81,21 @@
...
@@ -71,14 +81,21 @@
<
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_TYP
E_SCENE
,
CAR_TYPE_DESC
,
CAR_TIPS
,
TIP_LIST
}
from
'@/utils/constants'
import
{
CAR_TYP
R
,
CAR_TYPE_DESC
,
CAR_TIPS
,
ROLE_LIST
,
AI_TYPE
}
from
'@/utils/constants'
export
default
{
export
default
{
mixins
:
[
Socket
,
AudioToWord
],
mixins
:
[
Socket
,
AudioToWord
],
props
:
{
props
:
{
show
:
Boolean
show
:
Boolean
},
},
data
()
{
data
()
{
return
{
return
{
type
:
AI_TYPE
.
sparring
,
tip_1
:
''
,
tip_2
:
''
,
tip_3
:
''
,
tipIndex
:
1
,
tipList
:[],
timer_t
:
null
,
excercise
:
true
,
excercise
:
true
,
title
:
''
,
title
:
''
,
subTitle
:
''
,
subTitle
:
''
,
...
@@ -91,27 +108,30 @@ export default {
...
@@ -91,27 +108,30 @@ export default {
todayQuestionLeft
:
0
,
todayQuestionLeft
:
0
,
questionCountTotal
:
999
,
questionCountTotal
:
999
,
lastQuestionTime
:
''
,
lastQuestionTime
:
''
,
contentList
:
[{
contentType
:
2
,
content
:
'欢迎光临,您看上了哪款车?'
}],
padding
:
false
padding
:
false
}
}
},
},
beforeDestroy
()
{
beforeDestroy
()
{
clearInterval
(
this
.
timer
)
clearInterval
(
this
.
timer
)
clearInterval
(
this
.
timer_t
)
},
},
mounted
()
{
mounted
()
{
//获取传值
//获取传值
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
(
car_type
,
scene
,
identity
)
this
.
car_tips
=
CAR_TIPS
(
identity
)
this
.
title
=
`
${
type
}
`
//
this.title = `${type}`
this
.
subTitle
=
`在
${
scene
}
下以
${
identity
}
的身份提问
`
this
.
title
=
`AI的身份是
${
identity
}
购买的意向车型是问界
${
CAR_TYPR
[
identity
]}
`
this
.
issuesList
=
TIP_LIST
[
type
.
replace
(
/.*
?([
A-Za-z0-9
]
+
)
/
,
'$1'
)]
||
[
]
// this.issuesList = TIP_LIST[CAR_TYPR[identity]
]
},
},
methods
:
{
methods
:
{
getEvaluate
()
{
jumpEvaluate
()
{
//收集历史记录
let
history
=
[]
let
history
=
[]
setTimeout
(()
=>
{
this
.
contentList
.
forEach
((
item
,
index
)
=>
{
this
.
contentList
.
forEach
((
item
,
index
)
=>
{
if
(
index
%
2
==
0
&&
index
>
1
)
history
.
push
(
`
${
this
.
contentList
[
index
-
1
].
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
({
this
.
$router
.
push
({
name
:
'ai.evaluate'
,
name
:
'ai.evaluate'
,
...
@@ -120,7 +140,35 @@ export default {
...
@@ -120,7 +140,35 @@ export default {
history
history
}
}
})
})
},
3000
)
},
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
)
},
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
})
else
history
.
push
({
role
:
ROLE_LIST
.
assistant
,
content
:
this
.
contentList
[
i
].
content
})
}
}
this
.
pushMsg
(
AI_TYPE
.
sparring_reply
,
history
,
this
.
contentList
.
at
(
-
1
).
content
)
},
},
defaultFun
()
{
defaultFun
()
{
this
.
timer
=
setInterval
(()
=>
{
this
.
timer
=
setInterval
(()
=>
{
...
@@ -129,55 +177,11 @@ export default {
...
@@ -129,55 +177,11 @@ export default {
this
.
isSend
=
false
this
.
isSend
=
false
this
.
sendMessage
(
this
.
sendMessage
(
JSON
.
stringify
({
JSON
.
stringify
({
type
:
'sparring'
,
type
:
AI_TYPE
.
sparring
,
question
:
this
.
car_tips
question
:
this
.
car_tips
})
})
)
)
},
},
startRecording
()
{
let
recognition
=
new
webkitSpeechRecognition
()
// 创建语音识别对象
recognition
.
start
()
// 开始语音识别
recognition
.
onresult
=
function
(
event
)
{
const
result
=
event
.
results
[
0
][
0
].
transcript
// 获取语音识别结果
console
.
log
(
result
)
// 在控制台输出结果(可以根据需要进行其他处理)
}
},
touchstart
(
e
)
{
e
.
preventDefault
()
//阻止默认事件
this
.
timeOut
=
setTimeout
(()
=>
{
console
.
log
(
'在这里执行长按事件---'
)
wx
.
startRecord
({
success
:
()
=>
{
this
.
voiceTimer
=
setInterval
(()
=>
{
this
.
voiceTime
++
},
1000
)
this
.
voiceEnd
()
},
cancel
:
()
=>
{
Toast
(
'用户拒绝授权录音'
)
}
})
//开始录音
this
.
timeOut
=
0
//若开始录音,timeOut=0,当结束录音时,执行停止录音函数
this
.
isRecord
=
true
},
500
)
},
touchend
(
e
)
{
e
.
preventDefault
()
clearTimeout
(
this
.
timeOut
)
//结束录音时清除定时器
if
(
this
.
timeOut
!=
0
)
{
//点击事件的逻辑
this
.
$toast
.
show
(
'长按录音'
)
}
else
{
//长按事件的逻辑
if
(
this
.
isRecord
)
{
this
.
endSpeek
()
this
.
isRecord
=
false
}
else
{
return
}
}
},
onkeydown
(
e
)
{
onkeydown
(
e
)
{
if
(
e
.
keyCode
==
13
)
{
if
(
e
.
keyCode
==
13
)
{
this
.
send
()
this
.
send
()
...
@@ -187,28 +191,45 @@ export default {
...
@@ -187,28 +191,45 @@ export default {
if
(
i
&&
this
.
isSend
)
{
if
(
i
&&
this
.
isSend
)
{
this
.
issue
=
i
this
.
issue
=
i
}
}
if
(
!
this
.
issue
)
{
if
(
!
this
.
issue
||
!
this
.
isSend
)
{
return
return
}
}
this
.
tipIndex
=
1
;
this
.
tip_1
=
''
this
.
tip_2
=
''
let
history
=
[]
let
history
=
[]
if
(
this
.
contentList
.
length
)
{
if
(
this
.
contentList
.
length
)
{
this
.
contentList
.
forEach
((
item
,
index
)
=>
{
for
(
let
i
=
0
;
i
<
this
.
contentList
.
length
;
i
++
){
if
(
index
==
0
)
{
if
(
i
==
0
)
{
history
.
push
(
`
${
this
.
car_tips
}
::
${
this
.
contentList
[
index
].
content
}
`
)
history
.
push
({
"role"
:
ROLE_LIST
.
system
,
"content"
:
"你需要扮演一个购车客户,模拟购车客户与我(销售人员)对话,你只能提问题,不要回答购车客户的问题。"
},{
role
:
'assistant'
,
content
:
this
.
car_tips
})
}
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
})
}
}
if
(
index
%
2
==
0
&&
index
>
1
)
history
.
push
(
`
${
this
.
contentList
[
index
-
1
].
content
}
::
${
this
.
contentList
[
index
].
content
}
`
)
})
}
}
this
.
pushMsg
(
'sparring'
,
history
)
this
.
pushMsg
(
AI_TYPE
.
sparring
,
history
)
}
}
}
}
}
}
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.sum-btn
{
position
:
fixed
;
bottom
:
250px
;
z-index
:
999
;
right
:
0px
;
width
:
20px
;
border-radius
:
10px
;
padding
:
4px
;
color
:
#fff
;
background-color
:
#1989fa
;
border
:
1px
solid
#1989fa
;
text-align
:
center
;
}
.chat-gpt-box
{
.chat-gpt-box
{
background
:
#fff
;
background
:
#fff
;
height
:
calc
(
100vh
-
72
px
-
var
(
--constantSafeAreaInsetBottom
));
height
:
calc
(
100vh
-
46
px
-
var
(
--constantSafeAreaInsetBottom
));
height
:
calc
(
100vh
-
72
px
-
var
(
--envSafeAreaInsetBottom
));
height
:
calc
(
100vh
-
46
px
-
var
(
--envSafeAreaInsetBottom
));
.header-box
{
.header-box
{
padding
:
10px
;
padding
:
10px
;
width
:
100%
;
width
:
100%
;
...
@@ -233,12 +254,12 @@ export default {
...
@@ -233,12 +254,12 @@ export default {
background-color
:
#fff
;
background-color
:
#fff
;
}
}
.view
{
.view
{
height
:
calc
(
100%
-
72
px
);
height
:
calc
(
100%
-
46
px
);
overflow-y
:
scroll
;
overflow-y
:
scroll
;
position
:
relative
;
position
:
relative
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
padding-bottom
:
12px
;
padding-bottom
:
12px
;
margin-top
:
72
px
;
margin-top
:
46
px
;
background-color
:
#fff
;
background-color
:
#fff
;
.content-item
{
.content-item
{
...
@@ -261,6 +282,14 @@ export default {
...
@@ -261,6 +282,14 @@ export default {
color
:
#333333
;
color
:
#333333
;
line-height
:
22px
;
line-height
:
22px
;
word-break
:
break-all
;
word-break
:
break-all
;
.dot
{
display
:
inline-block
;
width
:
3px
;
height
:
3px
;
background
:
#333333
;
border-radius
:
50%
;
margin-right
:
2px
;
}
}
}
}
}
...
...
src/views/ai/evaluate.vue
View file @
6123420
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
<
script
>
<
script
>
import
Socket
from
'@/mixins/socket'
import
Socket
from
'@/mixins/socket'
import
MarkdownIt
from
'markdown-it'
import
MarkdownIt
from
'markdown-it'
import
{
AI_TYPE
}
from
'@/utils/constants'
export
default
{
export
default
{
mixins
:
[
Socket
],
mixins
:
[
Socket
],
data
()
{
data
()
{
...
@@ -100,7 +101,7 @@ export default {
...
@@ -100,7 +101,7 @@ export default {
defaultFun
()
{
defaultFun
()
{
this
.
sendMessage
(
this
.
sendMessage
(
JSON
.
stringify
({
JSON
.
stringify
({
type
:
'summarize'
,
type
:
AI_TYPE
.
summarize
,
question
:
'请按照对各个评估项目进行打分,给出每个单项的分数和总的分数 并给出具体理由和建议'
,
question
:
'请按照对各个评估项目进行打分,给出每个单项的分数和总的分数 并给出具体理由和建议'
,
history
:
JSON
.
stringify
(
this
.
history
)
history
:
JSON
.
stringify
(
this
.
history
)
})
})
...
...
src/views/ai/index.vue
View file @
6123420
...
@@ -2,14 +2,17 @@
...
@@ -2,14 +2,17 @@
* @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-02-2
7 15:02:45
* @LastEditTime: 2024-02-2
9 09:42:09
* @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
-->
-->
<
template
>
<
template
>
<div
class=
"ai-container"
>
<div
class=
"ai-container"
>
<div
class=
"ai-bg"
>
<img
src=
"https://p1-hera.feishucdn.com/tos-cn-i-jbbdkfciu3/5530b42d3b0c43acbf4137bc48603df3~tplv-jbbdkfciu3-image:0:0.image"
/>
</div>
<div
class=
"ai-box"
>
<div
class=
"ai-box"
>
<
div
class=
"ai-btn"
@
click=
"jumpX"
>
AI学习
</div
>
<
!--
<div
class=
"ai-btn"
@
click=
"jumpX"
>
AI学习
</div>
--
>
<div
class=
"ai-btn"
@
click=
"jump"
>
AI对练
</div>
<div
class=
"ai-btn"
@
click=
"jump"
>
AI对练
</div>
<div
class=
"ai-btn"
@
click=
"jumpQuestion"
>
AI问答
</div>
<div
class=
"ai-btn"
@
click=
"jumpQuestion"
>
AI问答
</div>
</div>
</div>
...
@@ -43,20 +46,25 @@ export default {
...
@@ -43,20 +46,25 @@ export default {
.ai-container
{
.ai-container
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
background
:
url('https://img1.baidu.com/it/u=476933213,3850346216&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=1422')
;
}
background-size
:
100%
100%
;
.ai-bg
{
width
:
100%
;
height
:
240px
;
}
}
.ai-box
{
.ai-box
{
padding-top
:
30vh
;
padding-top
:
100px
;
height
:
calc
(
100%
-
240px
);
box-sizing
:
border-box
;
background-color
:
rgba
(
225
,
234
,
255
,
0.3
);
}
}
.ai-btn
{
.ai-btn
{
color
:
#fff
;
color
:
#fff
;
background-color
:
#1989fa
;
background
:
var
(
--token-ai-primary-fill-default
,
linear-gradient
(
135deg
,
#5b65f5
0
,
#de81de
100%
));
border
:
1px
solid
#1989fa
;
width
:
300px
;
width
:
300px
;
height
:
40px
;
height
:
40px
;
border-radius
:
20px
;
line-height
:
40px
;
line-height
:
40px
;
margin
:
1
0
auto
;
margin
:
1
5px
auto
;
text-align
:
center
;
text-align
:
center
;
font-size
:
16px
;
font-size
:
16px
;
}
}
...
...
src/views/ai/questions.vue
View file @
6123420
This diff is collapsed.
Click to expand it.
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