|
@@ -40,11 +40,20 @@
|
|
|
<audioCom @onLoading="onLoading" @onAudio="onAudio"/>
|
|
|
</div>
|
|
|
<div class="cibo-split"/>
|
|
|
- <el-tooltip content="发送" placement="top">
|
|
|
- <div class="cibo-send __hover" @click="onSend()">
|
|
|
- <img src="@/views/smart-ask-answer/assistant/imgs/send.png"/>
|
|
|
- </div>
|
|
|
- </el-tooltip>
|
|
|
+ <template v-if="state.waiting && state.chats[state.chats.length - 1]?.taskId">
|
|
|
+ <el-tooltip content="停止生成" placement="top">
|
|
|
+ <div class="cibo-send __hover" @click="onStop()">
|
|
|
+ <div style="width: 13px;height: 13px;border-radius: 2px;background-color: #ffffff"/>
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <el-tooltip content="发送" placement="top">
|
|
|
+ <div class="cibo-send __hover" @click="onSend()">
|
|
|
+ <img src="@/views/smart-ask-answer/assistant-2/imgs/send.png"/>
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -82,7 +91,8 @@ const state: any = reactive({
|
|
|
badMap: new Map(),
|
|
|
autoList: [],
|
|
|
chatConfig: {},
|
|
|
- isSuggest: true
|
|
|
+ isSuggest: true,
|
|
|
+ isStop: false,
|
|
|
})
|
|
|
const ref_text = ref()
|
|
|
const ref_chatMsg = ref()
|
|
@@ -127,6 +137,7 @@ const onSend = (text = '') => {
|
|
|
type: 'answer',
|
|
|
content: '',
|
|
|
messageId: '',
|
|
|
+ taskId: '',
|
|
|
suggest: [],
|
|
|
loading: true
|
|
|
})
|
|
@@ -140,6 +151,8 @@ const onSend = (text = '') => {
|
|
|
body: state.params,
|
|
|
}, {
|
|
|
onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId }: any) => {
|
|
|
+ answer.messageId = messageId
|
|
|
+ answer.taskId = taskId
|
|
|
answer.loading = false
|
|
|
answer.content += message
|
|
|
scrollToEnd()
|
|
@@ -152,27 +165,33 @@ const onSend = (text = '') => {
|
|
|
post(`/installed-apps/${window.czrConfig.dify.appId}/conversations/${state.params.conversation_id}/name`, {body: {auto_generate: false, name: YMDHms(new Date())}})
|
|
|
}
|
|
|
answer.messageId = messageEnd.message_id
|
|
|
+ answer.taskId = messageEnd.task_id
|
|
|
state.params.parent_message_id = messageEnd.message_id
|
|
|
state.waiting = false
|
|
|
- if (state.chatConfig?.suggested_questions_after_answer?.enabled && state.isSuggest) {
|
|
|
- const warningStr1 = state.chatConfig?.sensitive_word_avoidance?.config?.outputs_config?.preset_response
|
|
|
- if (warningStr1 && answer.content.includes(warningStr1)) {
|
|
|
- return
|
|
|
- }
|
|
|
- const warningStr2 = state.chatConfig?.sensitive_word_avoidance?.config?.inputs_config?.preset_response
|
|
|
- if (warningStr2 && warningStr2.split('\n').some(v => answer.content.includes(v))) {
|
|
|
- return
|
|
|
+ if (!state.isStop) {
|
|
|
+ if (state.chatConfig?.suggested_questions_after_answer?.enabled && state.isSuggest) {
|
|
|
+ const warningStr1 = state.chatConfig?.sensitive_word_avoidance?.config?.outputs_config?.preset_response
|
|
|
+ if (warningStr1 && answer.content.includes(warningStr1)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const warningStr2 = state.chatConfig?.sensitive_word_avoidance?.config?.inputs_config?.preset_response
|
|
|
+ if (warningStr2 && warningStr2.split('\n').some(v => answer.content.includes(v))) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fetchSuggestedQuestions(state.params.parent_message_id, true, window.czrConfig.dify.appId).then((res: any) => {
|
|
|
+ answer.suggest = res.data
|
|
|
+ scrollToEnd()
|
|
|
+ })
|
|
|
}
|
|
|
- fetchSuggestedQuestions(state.params.parent_message_id, true, window.czrConfig.dify.appId).then((res: any) => {
|
|
|
- answer.suggest = res.data
|
|
|
- scrollToEnd()
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ state.isStop = false
|
|
|
}
|
|
|
},
|
|
|
onMessageReplace: (messageReplace) => {},
|
|
|
onError(msg, code) {
|
|
|
console.error(msg, code)
|
|
|
state.waiting = false
|
|
|
+ state.isStop = false
|
|
|
},
|
|
|
onWorkflowStarted: ({ workflow_run_id, task_id }) => {},
|
|
|
onWorkflowFinished: ({ data: workflowFinishedData }) => {},
|
|
@@ -186,6 +205,17 @@ const onSend = (text = '') => {
|
|
|
getRelation(state.params.query)
|
|
|
}
|
|
|
}
|
|
|
+const onStop = () => {
|
|
|
+ post(`/installed-apps/${window.czrConfig.dify.appId}/chat-messages/${state.chats[state.chats.length - 1].taskId}/stop`, {}).then((res: any) => {
|
|
|
+ if (res.result === 'success') {
|
|
|
+ state.isStop = true
|
|
|
+ setTimeout(() => {
|
|
|
+ state.isStop = false
|
|
|
+ state.waiting = false
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
const getRelation = (text) => {
|
|
|
emit('loadingSuggest')
|
|
|
let relation = ''
|