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
aa93172c
authored
May 22, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【解决todo】AI Chat 增加 useContext 控制
parent
689d92dc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
src/api/ai/chat/message/index.ts
+3
-1
src/views/ai/chat/index.vue
+5
-1
No files found.
src/api/ai/chat/message/index.ts
View file @
aa93172c
...
@@ -39,6 +39,7 @@ export const ChatMessageApi = {
...
@@ -39,6 +39,7 @@ export const ChatMessageApi = {
conversationId
:
number
,
conversationId
:
number
,
content
:
string
,
content
:
string
,
ctrl
,
ctrl
,
enableContext
:
boolean
,
onMessage
,
onMessage
,
onError
,
onError
,
onClose
onClose
...
@@ -53,7 +54,8 @@ export const ChatMessageApi = {
...
@@ -53,7 +54,8 @@ export const ChatMessageApi = {
openWhenHidden
:
true
,
openWhenHidden
:
true
,
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
conversationId
,
conversationId
,
content
content
,
useContext
:
enableContext
,
}),
}),
onmessage
:
onMessage
,
onmessage
:
onMessage
,
onerror
:
onError
,
onerror
:
onError
,
...
...
src/views/ai/chat/index.vue
View file @
aa93172c
...
@@ -54,7 +54,9 @@
...
@@ -54,7 +54,9 @@
placeholder=
"问我任何问题...(Shift+Enter 换行,按下 Enter 发送)"
placeholder=
"问我任何问题...(Shift+Enter 换行,按下 Enter 发送)"
></textarea>
></textarea>
<div
class=
"prompt-btns"
>
<div
class=
"prompt-btns"
>
<el-switch/>
<div>
<el-switch
v-model=
"enableContext"
/>
<span
style=
"font-size: 14px; color: #8f8f8f;"
>
上下文
</span>
</div>
<el-button
<el-button
type=
"primary"
type=
"primary"
size=
"default"
size=
"default"
...
@@ -110,6 +112,7 @@ const conversationInAbortController = ref<any>() // 对话进行中 abort 控制
...
@@ -110,6 +112,7 @@ const conversationInAbortController = ref<any>() // 对话进行中 abort 控制
const
inputTimeout
=
ref
<
any
>
()
// 处理输入中回车的定时器
const
inputTimeout
=
ref
<
any
>
()
// 处理输入中回车的定时器
const
prompt
=
ref
<
string
>
()
// prompt
const
prompt
=
ref
<
string
>
()
// prompt
const
userInfo
=
ref
<
ProfileVO
>
()
// 用户信息
const
userInfo
=
ref
<
ProfileVO
>
()
// 用户信息
const
enableContext
=
ref
<
boolean
>
(
true
)
// 是否开启上下文
const
fullText
=
ref
(
''
);
const
fullText
=
ref
(
''
);
const
displayedText
=
ref
(
''
);
const
displayedText
=
ref
(
''
);
...
@@ -327,6 +330,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
...
@@ -327,6 +330,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
userMessage
.
conversationId
,
// TODO 芋艿:这里可能要在优化;
userMessage
.
conversationId
,
// TODO 芋艿:这里可能要在优化;
userMessage
.
content
,
userMessage
.
content
,
conversationInAbortController
.
value
,
conversationInAbortController
.
value
,
enableContext
.
value
,
async
(
message
)
=>
{
async
(
message
)
=>
{
const
data
=
JSON
.
parse
(
message
.
data
)
// TODO 芋艿:类型处理;
const
data
=
JSON
.
parse
(
message
.
data
)
// TODO 芋艿:类型处理;
// 如果内容为空,就不处理。
// 如果内容为空,就不处理。
...
...
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