Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bd5262e2
authored
May 15, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【新增】AI:聊天更新的窗口
parent
ebd593bf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
36 deletions
+156
-36
src/api/ai/chat/conversation/index.ts
+5
-5
src/api/ai/model/chatRole/index.ts
+1
-2
src/views/ai/chat/components/ChatConversationUpdateForm.vue
+124
-0
src/views/ai/chat/index.vue
+22
-14
src/views/ai/model/chatRole/ChatRoleForm.vue
+3
-13
src/views/ai/model/chatRole/index.vue
+1
-2
No files found.
src/api/ai/chat/conversation/index.ts
View file @
bd5262e2
...
@@ -20,12 +20,12 @@ export interface ChatConversationVO {
...
@@ -20,12 +20,12 @@ export interface ChatConversationVO {
// AI 聊天会话 API
// AI 聊天会话 API
export
const
ChatConversationApi
=
{
export
const
ChatConversationApi
=
{
// 获
取 Conversation
// 获
得【我的】聊天会话
get
:
async
(
id
:
string
)
=>
{
get
ChatConversationMy
:
async
(
id
:
string
)
=>
{
return
await
request
.
get
({
url
:
`/ai/chat/conversation/get?id=
${
id
}
`
})
return
await
request
.
get
({
url
:
`/ai/chat/conversation/get
-my
?id=
${
id
}
`
})
},
},
// 更新
Conversation
// 更新
【我的】聊天会话
updateConversationMy
:
async
(
data
:
ChatConversationVO
)
=>
{
updateC
hatC
onversationMy
:
async
(
data
:
ChatConversationVO
)
=>
{
return
await
request
.
put
({
url
:
`/ai/chat/conversation/update-my`
,
data
})
return
await
request
.
put
({
url
:
`/ai/chat/conversation/update-my`
,
data
})
},
},
...
...
src/api/ai/model/chatRole/index.ts
View file @
bd5262e2
...
@@ -9,8 +9,7 @@ export interface ChatRoleVO {
...
@@ -9,8 +9,7 @@ export interface ChatRoleVO {
category
:
string
// 角色类别
category
:
string
// 角色类别
sort
:
number
// 角色排序
sort
:
number
// 角色排序
description
:
string
// 角色描述
description
:
string
// 角色描述
welcomeMessage
:
string
// 角色欢迎语
systemMessage
:
string
// 角色设定
systemMessage
:
string
// 角色上下文
publicStatus
:
boolean
// 是否公开
publicStatus
:
boolean
// 是否公开
status
:
number
// 状态
status
:
number
// 状态
}
}
...
...
src/views/ai/chat/components/ChatConversationUpdateForm.vue
0 → 100644
View file @
bd5262e2
<
template
>
<Dialog
title=
"设定"
v-model=
"dialogVisible"
>
<el-form
ref=
"formRef"
:model=
"formData"
:rules=
"formRules"
label-width=
"100px"
v-loading=
"formLoading"
>
<el-form-item
label=
"角色设定"
prop=
"systemContext"
>
<el-input
type=
"textarea"
v-model=
"formData.systemContext"
placeholder=
"请输入角色设定"
/>
</el-form-item>
<el-form-item
label=
"模型"
prop=
"modelId"
>
<UploadImg
v-model=
"formData.modelId"
/>
</el-form-item>
<el-form-item
label=
"上下文数量"
prop=
"category"
>
<el-input
v-model=
"formData.category"
placeholder=
"请输入角色类别"
/>
</el-form-item>
<el-form-item
label=
"话题随机性"
prop=
"description"
>
<el-input
type=
"textarea"
v-model=
"formData.description"
placeholder=
"请输入角色描述"
/>
</el-form-item>
<el-form-item
label=
"回复数"
prop=
"systemMessage"
>
<el-input
type=
"textarea"
v-model=
"formData.systemMessage"
placeholder=
"请输入角色设定"
/>
</el-form-item>
</el-form>
<template
#
footer
>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"dialogVisible = false"
>
取 消
</el-button>
</
template
>
</Dialog>
</template>
<
script
setup
lang=
"ts"
>
import
{
ChatRoleApi
,
ChatRoleVO
}
from
'@/api/ai/model/chatRole'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
import
{
ChatModelApi
,
ChatModelVO
}
from
'@/api/ai/model/chatModel'
import
{
ChatConversationApi
,
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
/** AI 聊天角色 表单 */
defineOptions
({
name
:
'ChatConversationUpdateForm'
})
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
dialogVisible
=
ref
(
false
)
// 弹窗的是否展示
const
formLoading
=
ref
(
false
)
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const
formData
=
ref
({
id
:
undefined
,
systemContext
:
undefined
,
modelId
:
undefined
,
name
:
undefined
,
avatar
:
undefined
,
category
:
undefined
,
sort
:
undefined
,
description
:
undefined
,
systemMessage
:
undefined
,
publicStatus
:
true
,
status
:
CommonStatusEnum
.
ENABLE
})
const
formRules
=
reactive
({
name
:
[{
required
:
true
,
message
:
'角色名称不能为空'
,
trigger
:
'blur'
}],
avatar
:
[{
required
:
true
,
message
:
'角色头像不能为空'
,
trigger
:
'blur'
}],
category
:
[{
required
:
true
,
message
:
'角色类别不能为空'
,
trigger
:
'blur'
}],
sort
:
[{
required
:
true
,
message
:
'角色排序不能为空'
,
trigger
:
'blur'
}],
description
:
[{
required
:
true
,
message
:
'角色描述不能为空'
,
trigger
:
'blur'
}],
systemMessage
:
[{
required
:
true
,
message
:
'角色设定不能为空'
,
trigger
:
'blur'
}],
publicStatus
:
[{
required
:
true
,
message
:
'是否公开不能为空'
,
trigger
:
'blur'
}]
})
const
formRef
=
ref
()
// 表单 Ref
const
chatModelList
=
ref
([]
as
ChatModelVO
[])
// 聊天模型列表
/** 打开弹窗 */
const
open
=
async
(
id
:
number
)
=>
{
dialogVisible
.
value
=
true
resetForm
()
// 修改时,设置数据
if
(
id
)
{
formLoading
.
value
=
true
try
{
formData
.
value
=
await
ChatConversationApi
.
getChatConversationMy
(
id
)
}
finally
{
formLoading
.
value
=
false
}
}
// 获得下拉数据
chatModelList
.
value
=
await
ChatModelApi
.
getChatModelSimpleList
(
CommonStatusEnum
.
ENABLE
)
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
submitForm
=
async
()
=>
{
// 校验表单
await
formRef
.
value
.
validate
()
// 提交请求
formLoading
.
value
=
true
try
{
const
data
=
formData
.
value
as
unknown
as
ChatRoleVO
await
ChatRoleApi
.
updateChatRole
(
data
)
message
.
success
(
t
(
'common.updateSuccess'
))
dialogVisible
.
value
=
false
// 发送操作成功的事件
emit
(
'success'
)
}
finally
{
formLoading
.
value
=
false
}
}
/** 重置表单 */
const
resetForm
=
()
=>
{
formData
.
value
=
{
id
:
undefined
,
modelId
:
undefined
,
name
:
undefined
,
avatar
:
undefined
,
category
:
undefined
,
sort
:
undefined
,
description
:
undefined
,
systemMessage
:
undefined
,
publicStatus
:
true
,
status
:
CommonStatusEnum
.
ENABLE
}
formRef
.
value
?.
resetFields
()
}
</
script
>
src/views/ai/chat/index.vue
View file @
bd5262e2
...
@@ -67,7 +67,8 @@
...
@@ -67,7 +67,8 @@
{{ useConversation?.title }}
{{ useConversation?.title }}
</div>
</div>
<div>
<div>
<el-dropdown
style=
"margin-right: 12px"
@
command=
"modalClick"
>
<!-- TODO @fan:样式改下;这里我已经改成点击后,弹出了 -->
<el-dropdown
style=
"margin-right: 12px"
@
command=
"openChatConversationUpdateForm"
>
<el-button
type=
"primary"
>
<el-button
type=
"primary"
>
<span
v-html=
"useModal?.name"
></span>
<span
v-html=
"useModal?.name"
></span>
<Icon
icon=
"ep:setting"
style=
"margin-left: 10px"
/>
<Icon
icon=
"ep:setting"
style=
"margin-left: 10px"
/>
...
@@ -185,6 +186,8 @@
...
@@ -185,6 +186,8 @@
</el-footer>
</el-footer>
</el-container>
</el-container>
</el-container>
</el-container>
<ChatConversationUpdateForm
ref=
"chatConversationUpdateFormRef"
/>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
...
@@ -194,6 +197,7 @@ import {
...
@@ -194,6 +197,7 @@ import {
ChatConversationUpdateVO
,
ChatConversationUpdateVO
,
ChatConversationVO
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
}
from
'@/api/ai/chat/conversation'
import
ChatConversationUpdateForm
from
'./components/ChatConversationUpdateForm.vue'
import
{
ChatModelApi
,
ChatModelVO
}
from
'@/api/ai/model/chatModel'
import
{
ChatModelApi
,
ChatModelVO
}
from
'@/api/ai/model/chatModel'
import
{
formatDate
}
from
'@/utils/formatTime'
import
{
formatDate
}
from
'@/utils/formatTime'
import
{
useClipboard
}
from
'@vueuse/core'
import
{
useClipboard
}
from
'@vueuse/core'
...
@@ -268,16 +272,17 @@ const updateConversationTitle = async (conversation: ChatConversationVO) => {
...
@@ -268,16 +272,17 @@ const updateConversationTitle = async (conversation: ChatConversationVO) => {
inputValue
:
conversation
.
title
inputValue
:
conversation
.
title
})
})
// 发起修改
// 发起修改
await
ChatConversationApi
.
updateConversationMy
({
await
ChatConversationApi
.
updateC
hatC
onversationMy
({
id
:
conversation
.
id
,
id
:
conversation
.
id
,
title
:
value
title
:
value
}
as
ChatConversationVO
)
}
as
ChatConversationVO
)
message
.
success
(
'
修改标题
成功'
)
message
.
success
(
'
重命名
成功'
)
// 刷新列表
// 刷新列表
await
getChatConversationList
()
await
getChatConversationList
()
}
}
const
deleteConversationTitle
=
(
conversation
)
=>
{
/** 删除聊天会话 */
const
deleteConversationTitle
=
async
(
conversation
:
ChatConversationVO
)
=>
{
console
.
log
(
conversation
)
console
.
log
(
conversation
)
// TODO 芋艿:待实现
// TODO 芋艿:待实现
}
}
...
@@ -453,15 +458,18 @@ const stopStream = async () => {
...
@@ -453,15 +458,18 @@ const stopStream = async () => {
conversationInProgress
.
value
=
false
conversationInProgress
.
value
=
false
}
}
const
modalClick
=
async
(
command
)
=>
{
/** 修改聊天会话 */
const
update
=
{
const
chatConversationUpdateFormRef
=
ref
()
id
:
conversationId
.
value
,
const
openChatConversationUpdateForm
=
async
(
command
)
=>
{
modelId
:
command
.
id
// const update = {
}
as
unknown
as
ChatConversationUpdateVO
// id: conversationId.value,
// 切换 modal
// modelId: command.id
useModal
.
value
=
command
// } as unknown as ChatConversationUpdateVO
// 更新
// // 切换 modal
await
ChatConversationApi
.
updateConversationMy
(
update
)
// useModal.value = command
// // 更新
// await ChatConversationApi.updateChatConversationMy(update)
chatConversationUpdateFormRef
.
value
.
open
(
conversationId
.
value
)
}
}
const
getModalList
=
async
()
=>
{
const
getModalList
=
async
()
=>
{
...
@@ -506,7 +514,7 @@ const onPromptInput = (event) => {
...
@@ -506,7 +514,7 @@ const onPromptInput = (event) => {
const
getConversation
=
async
(
conversationId
:
string
)
=>
{
const
getConversation
=
async
(
conversationId
:
string
)
=>
{
// 获取对话信息
// 获取对话信息
useConversation
.
value
=
await
ChatConversationApi
.
get
(
conversationId
)
useConversation
.
value
=
await
ChatConversationApi
.
get
ChatConversationMy
(
conversationId
)
console
.
log
(
'useConversation.value'
,
useConversation
.
value
)
console
.
log
(
'useConversation.value'
,
useConversation
.
value
)
// 选中 modal
// 选中 modal
if
(
useConversation
.
value
)
{
if
(
useConversation
.
value
)
{
...
...
src/views/ai/model/chatRole/ChatRoleForm.vue
View file @
bd5262e2
...
@@ -29,15 +29,8 @@
...
@@ -29,15 +29,8 @@
<el-form-item
label=
"角色描述"
prop=
"description"
>
<el-form-item
label=
"角色描述"
prop=
"description"
>
<el-input
type=
"textarea"
v-model=
"formData.description"
placeholder=
"请输入角色描述"
/>
<el-input
type=
"textarea"
v-model=
"formData.description"
placeholder=
"请输入角色描述"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"角色欢迎语"
prop=
"welcomeMessage"
>
<el-form-item
label=
"角色设定"
prop=
"systemMessage"
>
<el-input
<el-input
type=
"textarea"
v-model=
"formData.systemMessage"
placeholder=
"请输入角色设定"
/>
type=
"textarea"
v-model=
"formData.welcomeMessage"
placeholder=
"请输入角色欢迎语"
/>
</el-form-item>
<el-form-item
label=
"角色上下文"
prop=
"systemMessage"
>
<el-input
type=
"textarea"
v-model=
"formData.systemMessage"
placeholder=
"请输入角色上下文"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"是否公开"
prop=
"publicStatus"
>
<el-form-item
label=
"是否公开"
prop=
"publicStatus"
>
<el-radio-group
v-model=
"formData.publicStatus"
>
<el-radio-group
v-model=
"formData.publicStatus"
>
...
@@ -95,7 +88,6 @@ const formData = ref({
...
@@ -95,7 +88,6 @@ const formData = ref({
category
:
undefined
,
category
:
undefined
,
sort
:
undefined
,
sort
:
undefined
,
description
:
undefined
,
description
:
undefined
,
welcomeMessage
:
undefined
,
systemMessage
:
undefined
,
systemMessage
:
undefined
,
publicStatus
:
true
,
publicStatus
:
true
,
status
:
CommonStatusEnum
.
ENABLE
status
:
CommonStatusEnum
.
ENABLE
...
@@ -106,8 +98,7 @@ const formRules = reactive({
...
@@ -106,8 +98,7 @@ const formRules = reactive({
category
:
[{
required
:
true
,
message
:
'角色类别不能为空'
,
trigger
:
'blur'
}],
category
:
[{
required
:
true
,
message
:
'角色类别不能为空'
,
trigger
:
'blur'
}],
sort
:
[{
required
:
true
,
message
:
'角色排序不能为空'
,
trigger
:
'blur'
}],
sort
:
[{
required
:
true
,
message
:
'角色排序不能为空'
,
trigger
:
'blur'
}],
description
:
[{
required
:
true
,
message
:
'角色描述不能为空'
,
trigger
:
'blur'
}],
description
:
[{
required
:
true
,
message
:
'角色描述不能为空'
,
trigger
:
'blur'
}],
welcomeMessage
:
[{
required
:
true
,
message
:
'角色欢迎语不能为空'
,
trigger
:
'blur'
}],
systemMessage
:
[{
required
:
true
,
message
:
'角色设定不能为空'
,
trigger
:
'blur'
}],
systemMessage
:
[{
required
:
true
,
message
:
'角色上下文不能为空'
,
trigger
:
'blur'
}],
publicStatus
:
[{
required
:
true
,
message
:
'是否公开不能为空'
,
trigger
:
'blur'
}]
publicStatus
:
[{
required
:
true
,
message
:
'是否公开不能为空'
,
trigger
:
'blur'
}]
})
})
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
...
@@ -167,7 +158,6 @@ const resetForm = () => {
...
@@ -167,7 +158,6 @@ const resetForm = () => {
category
:
undefined
,
category
:
undefined
,
sort
:
undefined
,
sort
:
undefined
,
description
:
undefined
,
description
:
undefined
,
welcomeMessage
:
undefined
,
systemMessage
:
undefined
,
systemMessage
:
undefined
,
publicStatus
:
true
,
publicStatus
:
true
,
status
:
CommonStatusEnum
.
ENABLE
status
:
CommonStatusEnum
.
ENABLE
...
...
src/views/ai/model/chatRole/index.vue
View file @
bd5262e2
...
@@ -68,8 +68,7 @@
...
@@ -68,8 +68,7 @@
</el-table-column>
</el-table-column>
<el-table-column
label=
"角色类别"
align=
"center"
prop=
"category"
/>
<el-table-column
label=
"角色类别"
align=
"center"
prop=
"category"
/>
<el-table-column
label=
"角色描述"
align=
"center"
prop=
"description"
/>
<el-table-column
label=
"角色描述"
align=
"center"
prop=
"description"
/>
<el-table-column
label=
"角色欢迎语"
align=
"center"
prop=
"welcomeMessage"
/>
<el-table-column
label=
"角色设定"
align=
"center"
prop=
"systemMessage"
/>
<el-table-column
label=
"角色上下文"
align=
"center"
prop=
"systemMessage"
/>
<el-table-column
label=
"是否公开"
align=
"center"
prop=
"publicStatus"
>
<el-table-column
label=
"是否公开"
align=
"center"
prop=
"publicStatus"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.INFRA_BOOLEAN_STRING"
:value=
"scope.row.publicStatus"
/>
<dict-tag
:type=
"DICT_TYPE.INFRA_BOOLEAN_STRING"
:value=
"scope.row.publicStatus"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment