|
@@ -1,8 +1,11 @@
|
|
|
<script setup lang="ts">
|
|
|
+import { watch } from 'vue'
|
|
|
import AChat from '@/views/OaSystem/aiQA/components/AChat.vue'
|
|
|
import ExampleChat from '@/views/OaSystem/aiQA/components/ExampleChat.vue'
|
|
|
import sendImg from '@/assets/imgs/ai/send.png'
|
|
|
import QChat from '@/views/OaSystem/aiQA/components/QChat.vue'
|
|
|
+import useSSE from '@/hooks/web/useSSE'
|
|
|
+import { kbChat } from '@/service/aiService'
|
|
|
|
|
|
interface ChatContentProps {
|
|
|
currentQuestion: string
|
|
@@ -12,9 +15,10 @@ interface ChatContentProps {
|
|
|
const props = defineProps<ChatContentProps>()
|
|
|
const { currentQuestion } = toRefs(props)
|
|
|
const { changeQuestion } = props
|
|
|
-
|
|
|
const textarea = ref('')
|
|
|
|
|
|
+const { data, mutation: startChat } = useSSE({ mutationFn: kbChat })
|
|
|
+
|
|
|
const handleClear = () => {
|
|
|
changeQuestion('')
|
|
|
}
|
|
@@ -23,6 +27,13 @@ const handleSend = () => {
|
|
|
changeQuestion(textarea.value)
|
|
|
textarea.value = ''
|
|
|
}
|
|
|
+
|
|
|
+/*监控问题变化,开启问答*/
|
|
|
+watch(currentQuestion, (newVal) => {
|
|
|
+ if (newVal) {
|
|
|
+ startChat({ query: newVal })
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -30,7 +41,8 @@ const handleSend = () => {
|
|
|
<div class="message-body">
|
|
|
<template v-if="currentQuestion">
|
|
|
<QChat>{{ currentQuestion }}</QChat>
|
|
|
- <AChat> 生成中 </AChat>
|
|
|
+ <AChat v-if="data?.result?.['3'] == null"> {{ data.content }}</AChat>
|
|
|
+ <AChat v-else> {{ data?.result?.['3']?.choices?.[0]?.delta?.content }}</AChat>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<!-- 引导对话 -->
|