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
b0de27a7
authored
May 13, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】增加发送 stream 中可以进行取消
parent
c1b9baf8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
src/views/ai/chat/index.vue
+21
-3
No files found.
src/views/ai/chat/index.vue
View file @
b0de27a7
...
...
@@ -151,7 +151,12 @@
<textarea
class=
"prompt-input"
v-model=
"prompt"
@
keyup
.
enter=
"onSend"
placeholder=
"问我任何问题...(Shift+Enter 换行,按下 Enter 发送)"
></textarea>
<div
class=
"prompt-btns"
>
<el-switch/>
<el-button
type=
"primary"
size=
"default"
@
click=
"onSend()"
>
发送
</el-button>
<el-button
type=
"primary"
size=
"default"
@
click=
"onSend()"
:loading=
"conversationInProgress"
v-if=
"conversationInProgress == false"
>
{{ conversationInProgress ? '进行中' : '发送'}}
</el-button>
<el-button
type=
"danger"
size=
"default"
@
click=
"stopStream()"
v-if=
"conversationInProgress == true"
>
停止
</el-button>
</div>
</form>
</el-footer>
...
...
@@ -170,6 +175,8 @@ const { copy } = useClipboard();
const
searchName
=
ref
(
''
)
// 查询的内容
const
conversationId
=
ref
(
'1781604279872581648'
)
// 对话id
const
conversationInProgress
=
ref
<
Boolean
>
()
// 对话进行中
conversationInProgress
.
value
=
false
const
conversationInAbortController
=
ref
<
any
>
()
// 对话进行中 abort 控制器(控制 stream 对话)
const
prompt
=
ref
<
string
>
()
// prompt
...
...
@@ -204,6 +211,10 @@ const searchConversation = () => {
/** send */
const
onSend
=
async
()
=>
{
// 进行中不允许发送
if
(
conversationInProgress
.
value
)
{
return
}
const
content
=
prompt
.
value
;
// 清空输入框
prompt
.
value
=
''
...
...
@@ -323,11 +334,18 @@ const onDelete = async (id) => {
type
:
'success'
,
})
// tip:如果 stream 进行中的 message,就需要调用 controller 结束
stopStream
()
// 重新获取 message 列表
await
messageList
();
}
const
stopStream
=
async
()
=>
{
// tip:如果 stream 进行中的 message,就需要调用 controller 结束
if
(
conversationInAbortController
.
value
)
{
conversationInAbortController
.
value
.
abort
()
}
//
重新获取 message 列表
await
messageList
();
//
设置为 false
conversationInProgress
.
value
=
false
}
/** 初始化 **/
...
...
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