|
99 | 99 | :questions="message.recommended_question" |
100 | 100 | :first-chat="message.first_chat" |
101 | 101 | @click-question="quickAsk" |
| 102 | + @stop="onChatStop" |
102 | 103 | /> |
103 | 104 | <UserChat v-if="message.role === 'user'" :message="message" /> |
104 | 105 | <template v-if="message.role === 'assistant' && !message.first_chat"> |
|
118 | 119 | :reasoning-name="['sql_answer', 'chart_answer']" |
119 | 120 | @finish="onChartAnswerFinish" |
120 | 121 | @error="onChartAnswerError" |
| 122 | + @stop="onChatStop" |
121 | 123 | > |
122 | 124 | <ChartBlock style="margin-top: 12px" :message="message" /> |
123 | 125 | <div |
|
190 | 192 | :questions="message.recommended_question" |
191 | 193 | :first-chat="message.first_chat" |
192 | 194 | @click-question="quickAsk" |
| 195 | + @stop="onChatStop" |
193 | 196 | /> |
194 | 197 | </template> |
195 | 198 | </ChartAnswer> |
|
206 | 209 | :message="message" |
207 | 210 | @finish="onAnalysisAnswerFinish" |
208 | 211 | @error="onAnalysisAnswerError" |
| 212 | + @stop="onChatStop" |
209 | 213 | > |
210 | 214 | <div |
211 | 215 | v-if="message.record?.error && message.record?.error?.trim().length > 0" |
|
230 | 234 | :message="message" |
231 | 235 | @finish="onPredictAnswerFinish" |
232 | 236 | @error="onPredictAnswerError" |
| 237 | + @stop="onChatStop" |
233 | 238 | > |
234 | 239 | <ChartBlock style="margin-top: 12px" :message="message" is-predict /> |
235 | 240 | <div |
@@ -382,9 +387,9 @@ const computedMessages = computed<Array<ChatMessage>>(() => { |
382 | 387 | return messages |
383 | 388 | }) |
384 | 389 |
|
385 | | -const goEmpty = () => { |
| 390 | +const goEmpty = (func?: (...p: any[]) => void, ...param: any[]) => { |
386 | 391 | inputMessage.value = '' |
387 | | - stop() |
| 392 | + stop(func, ...param) |
388 | 393 | } |
389 | 394 |
|
390 | 395 | const createNewChatSimple = async () => { |
@@ -418,8 +423,8 @@ function getChatList() { |
418 | 423 | } |
419 | 424 |
|
420 | 425 | function onClickHistory(chat: Chat) { |
421 | | - console.log('click history', chat) |
422 | 426 | scrollToBottom() |
| 427 | + console.debug('click history', chat) |
423 | 428 | } |
424 | 429 |
|
425 | 430 | function toAssistantHistory(chat: Chat) { |
@@ -510,6 +515,13 @@ async function onChartAnswerFinish(id: number) { |
510 | 515 | function onChartAnswerError() { |
511 | 516 | loading.value = false |
512 | 517 | isTyping.value = false |
| 518 | + console.debug('onChartAnswerError') |
| 519 | +} |
| 520 | +
|
| 521 | +function onChatStop() { |
| 522 | + loading.value = false |
| 523 | + isTyping.value = false |
| 524 | + console.debug('onChatStop') |
513 | 525 | } |
514 | 526 |
|
515 | 527 | const sendMessage = async () => { |
@@ -698,7 +710,7 @@ function clickInput() { |
698 | 710 | inputRef.value?.focus() |
699 | 711 | } |
700 | 712 |
|
701 | | -function stop() { |
| 713 | +function stop(func?: (...p: any[]) => void, ...param: any[]) { |
702 | 714 | if (recommendQuestionRef.value) { |
703 | 715 | if (recommendQuestionRef.value instanceof Array) { |
704 | 716 | for (let i = 0; i < recommendQuestionRef.value.length; i++) { |
@@ -735,6 +747,9 @@ function stop() { |
735 | 747 | predictAnswerRef.value.stop() |
736 | 748 | } |
737 | 749 | } |
| 750 | + if (func && typeof func === 'function') { |
| 751 | + func(...param) |
| 752 | + } |
738 | 753 | } |
739 | 754 |
|
740 | 755 | onMounted(() => { |
|
0 commit comments