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
cea5b8b1
authored
May 14, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】chat 增加 modal 切换
parent
27569a74
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
4 deletions
+54
-4
src/api/ai/chat/conversation/index.ts
+37
-0
src/views/ai/chat/index.vue
+17
-4
No files found.
src/api/ai/chat/conversation/index.ts
0 → 100644
View file @
cea5b8b1
import
request
from
'@/config/axios'
// 聊天VO
export
interface
ChatConversationVO
{
id
:
string
// 会话编号
userId
:
string
// 用户编号
title
:
string
// 会话标题
pinned
:
string
// 是否置顶
roleId
:
string
// 角色编号
model
:
number
// 模型标志
modelId
:
number
// 模型编号
temperature
:
string
// 温度参数
maxTokens
:
string
// 单条回复的最大 Token 数量
maxContexts
:
string
// 上下文的最大 Message 数量
}
export
interface
ChatConversationUpdateVO
{
id
:
string
// 会话编号
title
:
string
// 会话标题
pinned
:
string
// 是否置顶
modelId
:
number
// 模型编号
temperature
:
string
// 温度参数
maxTokens
:
string
// 单条回复的最大 Token 数量
maxContexts
:
string
// 上下文的最大 Message 数量
}
// AI chat 聊天
export
const
ChatConversationApi
=
{
// 获取 Conversation
get
:
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/ai/chat/conversation/get?id=
${
id
}
`
})
},
// 更新 Conversation
update
:
async
(
data
:
ChatConversationUpdateVO
)
=>
{
return
await
request
.
put
({
url
:
`/ai/chat/conversation/update`
,
data
})
},
}
src/views/ai/chat/index.vue
View file @
cea5b8b1
...
@@ -72,11 +72,11 @@
...
@@ -72,11 +72,11 @@
<!-- </el-button>-->
<!-- </el-button>-->
<el-dropdown
style=
"margin-right: 12px;"
@
command=
"modalClick"
>
<el-dropdown
style=
"margin-right: 12px;"
@
command=
"modalClick"
>
<el-button
type=
"primary"
>
<el-button
type=
"primary"
>
GPT3.5
<Icon
icon=
"ep:setting"
style=
"margin-left: 10px;"
/>
<span
v-html=
"useModal?.name"
></span>
<Icon
icon=
"ep:setting"
style=
"margin-left: 10px;"
/>
</el-button>
</el-button>
<
template
#
dropdown
>
<
template
#
dropdown
>
<el-dropdown-menu
v-for=
"(item, index) in modalList"
:key=
"index"
>
<el-dropdown-menu
v-for=
"(item, index) in modalList"
:key=
"index"
>
<el-dropdown-item
:command=
"item
.model"
>
{{
item
.
model
}}
</el-dropdown-item>
<el-dropdown-item
:command=
"item
"
>
{{
item
.
name
}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown-menu>
</
template
>
</
template
>
</el-dropdown>
</el-dropdown>
...
@@ -176,7 +176,8 @@
...
@@ -176,7 +176,8 @@
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ChatMessageApi
,
ChatMessageSendVO
,
ChatMessageVO
}
from
"@/api/ai/chat/message"
import
{
ChatMessageApi
,
ChatMessageSendVO
,
ChatMessageVO
}
from
"@/api/ai/chat/message"
import
{
ChatModelApi
,
ChatModelVO
}
from
"@/api/ai/model/chatModel"
import
{
ChatConversationApi
,
ChatConversationUpdateVO
}
from
"@/api/ai/chat/conversation"
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"
;
// 转换 markdown
// 转换 markdown
...
@@ -230,6 +231,7 @@ const isScrolling = ref(false)//用于判断用户是否在滚动
...
@@ -230,6 +231,7 @@ const isScrolling = ref(false)//用于判断用户是否在滚动
/** chat message 列表 */
/** chat message 列表 */
// defineOptions({ name: 'chatMessageList' })
// defineOptions({ name: 'chatMessageList' })
const
list
=
ref
<
ChatMessageVO
[]
>
([])
// 列表的数据
const
list
=
ref
<
ChatMessageVO
[]
>
([])
// 列表的数据
const
useModal
=
ref
<
ChatModelVO
>
()
// 使用的modal
const
modalList
=
ref
<
ChatModelVO
[]
>
([])
// 列表的数据
const
modalList
=
ref
<
ChatModelVO
[]
>
([])
// 列表的数据
...
@@ -406,12 +408,23 @@ const stopStream = async () => {
...
@@ -406,12 +408,23 @@ const stopStream = async () => {
}
}
const
modalClick
=
async
(
command
)
=>
{
const
modalClick
=
async
(
command
)
=>
{
console
.
log
(
'22'
,
command
)
const
update
=
{
id
:
conversationId
.
value
,
modelId
:
command
.
id
,
}
as
unknown
as
ChatConversationUpdateVO
// 切换 modal
useModal
.
value
=
command
// 更新
await
ChatConversationApi
.
update
(
update
)
}
}
const
getModalList
=
async
()
=>
{
const
getModalList
=
async
()
=>
{
// 获取模型 as unknown as ChatModelVO
// 获取模型 as unknown as ChatModelVO
modalList
.
value
=
await
ChatModelApi
.
getChatModelSimpleList
(
0
)
as
unknown
as
ChatModelVO
[]
modalList
.
value
=
await
ChatModelApi
.
getChatModelSimpleList
(
0
)
as
unknown
as
ChatModelVO
[]
// 默认选中第一个模型
if
(
modalList
.
value
.
length
)
{
useModal
.
value
=
modalList
.
value
[
0
]
}
}
}
/** 初始化 **/
/** 初始化 **/
...
...
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