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
f14032d6
authored
May 16, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】AI 配置 Chat角色
parent
9658af7c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
+21
-11
src/api/ai/chat/message/index.ts
+3
-3
src/views/ai/chat/index.vue
+14
-7
src/views/ai/chat/role/index.vue
+4
-1
No files found.
src/api/ai/chat/message/index.ts
View file @
f14032d6
...
...
@@ -5,8 +5,8 @@ import { config } from '@/config/axios/config'
// 聊天VO
export
interface
ChatMessageVO
{
id
:
string
// 编号
conversationId
:
string
// 会话编号
id
:
number
// 编号
conversationId
:
number
// 会话编号
type
:
string
// 消息类型
userId
:
string
// 用户编号
roleId
:
string
// 角色编号
...
...
@@ -25,7 +25,7 @@ export interface ChatMessageSendVO {
// AI chat 聊天
export
const
ChatMessageApi
=
{
// 消息列表
messageList
:
async
(
conversationId
:
string
)
=>
{
messageList
:
async
(
conversationId
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/ai/chat/message/list-by-conversation-id?conversationId=
${
conversationId
}
`
})
...
...
src/views/ai/chat/index.vue
View file @
f14032d6
...
...
@@ -199,7 +199,7 @@ import { marked } from 'marked'
// 代码高亮 https://highlightjs.org/
import
'highlight.js/styles/vs2015.min.css'
import
hljs
from
'highlight.js'
const
route
=
useRoute
()
// 路由
const
message
=
useMessage
()
// 消息弹窗
// 自定义渲染器
...
...
@@ -220,7 +220,7 @@ const { copy } = useClipboard()
const
searchName
=
ref
(
''
)
// 查询的内容
const
inputTimeout
=
ref
<
any
>
()
// 处理输入中回车的定时器
const
conversationId
=
ref
(
0
)
// 选中的对话编号
const
conversationId
=
ref
<
number
>
(
-
1
)
// 选中的对话编号
const
conversationInProgress
=
ref
(
false
)
// 对话进行中
const
conversationInAbortController
=
ref
<
any
>
()
// 对话进行中 abort 控制器(控制 stream 对话)
...
...
@@ -297,7 +297,7 @@ const onSend = async () => {
if
(
conversationInProgress
.
value
)
{
return
}
const
content
=
prompt
.
value
?.
trim
()
const
content
=
prompt
.
value
?.
trim
()
+
''
if
(
content
.
length
<
2
)
{
ElMessage
({
message
:
'请输入内容!'
,
...
...
@@ -316,7 +316,7 @@ const onSend = async () => {
const
userMessage
=
{
conversationId
:
conversationId
.
value
,
content
:
content
}
}
as
ChatMessageVO
// list.value.push(userMessage)
// // 滚动到住下面
// scrollToBottom()
...
...
@@ -387,6 +387,9 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
/** 查询列表 */
const
messageList
=
async
()
=>
{
try
{
if
(
!
conversationId
.
value
)
{
return
}
// 获取列表数据
const
res
=
await
ChatMessageApi
.
messageList
(
conversationId
.
value
)
...
...
@@ -504,7 +507,7 @@ const onPromptInput = (event) => {
},
400
)
}
const
getConversation
=
async
(
conversationId
:
string
)
=>
{
const
getConversation
=
async
(
conversationId
:
number
)
=>
{
// 获取对话信息
useConversation
.
value
=
await
ChatConversationApi
.
getChatConversationMy
(
conversationId
)
console
.
log
(
'useConversation.value'
,
useConversation
.
value
)
...
...
@@ -527,12 +530,16 @@ const getChatConversationList = async () => {
/** 初始化 **/
onMounted
(
async
()
=>
{
// 设置当前对话
if
(
route
.
query
.
conversationId
)
{
conversationId
.
value
=
route
.
query
.
conversationId
as
number
}
// 获得聊天会话列表
await
getChatConversationList
()
// 获取对话信息
getConversation
(
conversationId
.
value
)
await
getConversation
(
conversationId
.
value
)
// 获取列表数据
messageList
()
await
messageList
()
// scrollToBottom();
// await nextTick
// 监听滚动事件,判断用户滚动状态
...
...
src/views/ai/chat/role/index.vue
View file @
f14032d6
...
...
@@ -149,7 +149,10 @@ const handlerCardUse = async (role) => {
const
conversation
=
await
ChatConversationApi
.
createChatConversationMy
(
data
)
// 调整页面
router
.
push
({
path
:
`/ai/chat/index?conversationId=
${
conversation
.
id
}
`
path
:
`/ai/chat/index`
,
query
:
{
conversationId
:
conversation
,
}
})
}
...
...
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