Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-dml
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-dml
Commits
c6a5b125
提交
c6a5b125
authored
11月 13, 2024
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: update
上级
d70ba4e0
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
102 行增加
和
5 行删除
+102
-5
useChat.js
src/composables/useChat.js
+51
-0
FormBaseInfo.vue
...dules/live/product/management/components/FormBaseInfo.vue
+49
-3
FormPrice.vue
src/modules/live/product/management/components/FormPrice.vue
+2
-2
没有找到文件。
src/composables/useChat.js
0 → 100644
浏览文件 @
c6a5b125
import
{
fetchEventSource
}
from
'@fortaine/fetch-event-source'
import
{
ElMessage
}
from
'element-plus'
export
function
useChat
()
{
const
messages
=
ref
([])
const
isLoading
=
ref
(
false
)
async
function
post
(
message
)
{
isLoading
.
value
=
true
await
fetchEventSource
(
'/api/lab/v1/experiment/qwen/chat'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
},
body
:
JSON
.
stringify
({
model
:
'qwen-long'
,
messages
:
[
message
]
}),
async
onopen
(
response
)
{
if
(
response
.
ok
)
{
return
response
}
else
{
throw
response
}
},
onmessage
(
res
)
{
console
.
log
(
res
.
data
)
try
{
const
message
=
JSON
.
parse
(
res
.
data
)
if
(
message
.
error
)
{
ElMessage
.
error
(
message
.
error
.
message
)
return
}
const
id
=
message
.
id
const
messageIndex
=
messages
.
value
.
findIndex
((
session
)
=>
session
.
id
===
id
)
let
content
=
message
?.
choices
[
0
]?.
delta
.
content
||
''
content
=
content
.
replaceAll
(
'
\
n'
,
'<br/>'
)
if
(
messageIndex
===
-
1
)
{
messages
.
value
.
push
({
id
,
role
:
'assistant'
,
content
})
}
else
{
messages
.
value
[
messageIndex
].
content
=
messages
.
value
[
messageIndex
].
content
+
content
}
isLoading
.
value
=
false
}
catch
(
error
)
{
console
.
log
(
error
)
isLoading
.
value
=
false
}
},
onerror
(
err
)
{
isLoading
.
value
=
false
throw
err
},
})
}
return
{
messages
,
post
,
isLoading
}
}
src/modules/live/product/management/components/FormBaseInfo.vue
浏览文件 @
c6a5b125
<
script
setup
>
<
script
setup
>
import
{
useChat
}
from
'@/composables/useChat'
import
{
getAttrList
}
from
'../api'
import
{
getAttrList
}
from
'../api'
const
form
=
inject
(
'form'
)
const
form
=
inject
(
'form'
)
const
{
post
,
messages
}
=
useChat
()
watch
(
messages
,
()
=>
{
const
lastMessage
=
messages
.
value
[
messages
.
value
.
length
-
1
]
if
(
lastMessage
)
{
form
.
shopping_guide_short_title
=
lastMessage
.
content
}
},
{
deep
:
true
}
)
function
handleAIGenerate
()
{
post
({
role
:
'user'
,
content
:
`请根据以下内容,给出1个用于抖音电商使用的推荐的“导购短标题”内容:
${
form
.
title
}
要求:
1. 标题要简洁明了,能够吸引消费者的注意力。
2. 标题要突出
${
form
.
title
}
的特点和优势,如设计、材质、功能等。
3. 标题要具有吸引力,能够激发消费者的购买欲望。
4. 标题要简洁明了,不要过于冗长或复杂。
5. 输出结果以“推荐导购短标题:”开始`
,
})
}
const
attrs
=
reactive
({
const
attrs
=
reactive
({
importance_attrs
:
{
importance_attrs
:
{
items
:
[],
items
:
[],
...
@@ -28,6 +54,22 @@ function handleChange(value, item, attr) {
...
@@ -28,6 +54,22 @@ function handleChange(value, item, attr) {
value
:
value
,
value
:
value
,
}
}
}
}
const
importanceTotal
=
computed
(()
=>
{
let
total
=
0
Object
.
values
(
form
.
live_commodity_attrs
.
importance_attrs
).
forEach
((
item
)
=>
{
if
(
item
.
value
)
total
++
})
return
total
})
const
unimportanceTotal
=
computed
(()
=>
{
let
total
=
0
Object
.
values
(
form
.
live_commodity_attrs
.
unimportance_attrs
).
forEach
((
item
)
=>
{
if
(
item
.
value
)
total
++
})
return
total
})
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -44,10 +86,12 @@ function handleChange(value, item, attr) {
...
@@ -44,10 +86,12 @@ function handleChange(value, item, attr) {
size=
"large"
size=
"large"
v-model=
"form.shopping_guide_short_title"
v-model=
"form.shopping_guide_short_title"
style=
"flex: 1"
/>
style=
"flex: 1"
/>
<el-button
type=
"primary"
plain
>
一键智能推荐
</el-button>
<el-button
type=
"primary"
plain
@
click=
"handleAIGenerate"
>
一键智能推荐
</el-button>
</div>
</div>
</el-form-item>
</el-form-item>
<el-form-item
:label=
"`重要属性 0/$
{attrs.importance_attrs.total}`" prop="live_commodity_attrs.importance_attrs">
<el-form-item
:label=
"`重要属性 $
{importanceTotal}/${attrs.importance_attrs.total}`"
prop="live_commodity_attrs.importance_attrs">
<div
class=
"form-tips"
>
错误填写属性,会引起商品下架,请认真准确填写。
</div>
<div
class=
"form-tips"
>
错误填写属性,会引起商品下架,请认真准确填写。
</div>
<el-form-item
<el-form-item
v-for=
"item in attrs.importance_attrs.items"
v-for=
"item in attrs.importance_attrs.items"
...
@@ -61,7 +105,9 @@ function handleChange(value, item, attr) {
...
@@ -61,7 +105,9 @@ function handleChange(value, item, attr) {
@
input=
"(value) => handleChange(value, item, 'importance_attrs')"
></el-input>
@
input=
"(value) => handleChange(value, item, 'importance_attrs')"
></el-input>
</el-form-item>
</el-form-item>
</el-form-item>
</el-form-item>
<el-form-item
:label=
"`非重要属性 0/$
{attrs.unimportance_attrs.total}`" prop="live_commodity_attrs.unimportance">
<el-form-item
:label=
"`非重要属性 $
{unimportanceTotal}/${attrs.unimportance_attrs.total}`"
prop="live_commodity_attrs.unimportance">
<el-form-item
<el-form-item
v-for=
"item in attrs.unimportance_attrs.items"
v-for=
"item in attrs.unimportance_attrs.items"
:key=
"item.id"
:key=
"item.id"
...
...
src/modules/live/product/management/components/FormPrice.vue
浏览文件 @
c6a5b125
...
@@ -43,10 +43,10 @@ const form = inject('form')
...
@@ -43,10 +43,10 @@ const form = inject('form')
<el-form-item
label=
"参考价"
prop=
"info.reference_price"
>
<el-form-item
label=
"参考价"
prop=
"info.reference_price"
>
<
template
#
label
>
<
template
#
label
>
<span>
参考价
</span>
<span>
参考价
</span>
<el-popover
:width=
"200"
trigger=
"hover"
content=
"this is content, this is content, this is conten
t"
>
<el-popover
:width=
"200"
trigger=
"hover"
placement=
"righ
t"
>
<img
src=
"/live/product.png"
style=
"width: 100%"
/>
<img
src=
"/live/product.png"
style=
"width: 100%"
/>
<template
#
reference
>
<template
#
reference
>
<QuestionFilled
style=
"width: 20px"
></QuestionFilled>
<QuestionFilled
style=
"width: 20px
; vertical-align: middle
"
></QuestionFilled>
</
template
>
</
template
>
</el-popover>
</el-popover>
</template>
</template>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论