|
@@ -212,7 +212,7 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { ref, onMounted, useTemplateRef, nextTick, watch } from 'vue'
|
|
import { ref, onMounted, useTemplateRef, nextTick, watch } from 'vue'
|
|
|
import { chat_no_stream, chat_stream, getAgentModel, chat_no_stream2 } from '@/tools/aiChat'
|
|
import { chat_no_stream, chat_stream, getAgentModel, chat_no_stream2 } from '@/tools/aiChat'
|
|
|
-import { useSlidesStore } from '@/store'
|
|
|
|
|
|
|
+import { useSlidesStore, useMainStore } from '@/store'
|
|
|
import { lang } from '@/main'
|
|
import { lang } from '@/main'
|
|
|
import MarkdownIt from 'markdown-it'
|
|
import MarkdownIt from 'markdown-it'
|
|
|
import { getWorkPageId } from '@/services/course'
|
|
import { getWorkPageId } from '@/services/course'
|
|
@@ -435,6 +435,7 @@ const sendQuickAction = (action: string) => {
|
|
|
import { v4 as uuidv4 } from 'uuid'
|
|
import { v4 as uuidv4 } from 'uuid'
|
|
|
const session_name = ref('')
|
|
const session_name = ref('')
|
|
|
const slidesStore = useSlidesStore()
|
|
const slidesStore = useSlidesStore()
|
|
|
|
|
+const mainStore = useMainStore()
|
|
|
const gType = ref('chat')
|
|
const gType = ref('chat')
|
|
|
|
|
|
|
|
const sendAction = async (action: string) => {
|
|
const sendAction = async (action: string) => {
|
|
@@ -480,7 +481,27 @@ const sendAction = async (action: string) => {
|
|
|
gType: gType.value,
|
|
gType: gType.value,
|
|
|
isGenerate: false
|
|
isGenerate: false
|
|
|
}
|
|
}
|
|
|
|
|
+ let isHave = 1
|
|
|
|
|
+ for (let i = 0; i < slidesStore.slides.length; i++) {
|
|
|
|
|
+ const slide = slidesStore.slides[i]
|
|
|
|
|
+ if (slide.toolsArray && slide.toolsArray.length > 0) {
|
|
|
|
|
+ const hasUnprocessed = slide.toolsArray.length
|
|
|
|
|
+ if (hasUnprocessed) {
|
|
|
|
|
+ isHave = 2
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isHave == 2) {
|
|
|
|
|
+ messages.value.at(-1).aiContent = lang.ssBatchInteractiveWebDesc3
|
|
|
|
|
+ messages.value.at(-1).loading = false
|
|
|
|
|
+ chatLoading.value = false
|
|
|
|
|
+ messages.value.at(-1).chatloading = false
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
messages.value.at(-1).aiContent = lang.ssBatchInteractiveWebDesc
|
|
messages.value.at(-1).aiContent = lang.ssBatchInteractiveWebDesc
|
|
|
|
|
+
|
|
|
// messages.value.at(-1).loading = false
|
|
// messages.value.at(-1).loading = false
|
|
|
// messages.value.at(-1).chatloading = false
|
|
// messages.value.at(-1).chatloading = false
|
|
|
// chatLoading.value = false
|
|
// chatLoading.value = false
|
|
@@ -515,11 +536,31 @@ const sendAction = async (action: string) => {
|
|
|
gType: 'trigger_batch_tool',
|
|
gType: 'trigger_batch_tool',
|
|
|
isGenerate: false
|
|
isGenerate: false
|
|
|
}
|
|
}
|
|
|
|
|
+ let isHave = 1
|
|
|
|
|
+ for (let i = 0; i < slidesStore.slides.length; i++) {
|
|
|
|
|
+ const slide = slidesStore.slides[i]
|
|
|
|
|
+ if (slide.toolsArray && slide.toolsArray.length > 0) {
|
|
|
|
|
+ const hasUnprocessed = slide.toolsArray.length
|
|
|
|
|
+ if (hasUnprocessed) {
|
|
|
|
|
+ isHave = 2
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isHave == 2) {
|
|
|
|
|
+ messages.value.at(-1).aiContent = lang.ssBatchInteractiveWebDesc3
|
|
|
|
|
+ messages.value.at(-1).loading = false
|
|
|
|
|
+ chatLoading.value = false
|
|
|
|
|
+ messages.value.at(-1).chatloading = false
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
messages.value.at(-1).aiContent = lang.ssBatchInteractiveWebDesc
|
|
messages.value.at(-1).aiContent = lang.ssBatchInteractiveWebDesc
|
|
|
|
|
+
|
|
|
// messages.value.at(-1).loading = false
|
|
// messages.value.at(-1).loading = false
|
|
|
// chatLoading.value = false
|
|
// chatLoading.value = false
|
|
|
// messages.value.at(-1).chatloading = false
|
|
// messages.value.at(-1).chatloading = false
|
|
|
- return
|
|
|
|
|
|
|
+ // return
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
@@ -635,25 +676,33 @@ const sendAction = async (action: string) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (gType.value === 'trigger_batch_tool') {
|
|
if (gType.value === 'trigger_batch_tool') {
|
|
|
- chat_stream(prompt, agentid, props.userid || '', lang.lang, async (event) => {
|
|
|
|
|
- if (event.type === 'message') {
|
|
|
|
|
- messages.value.at(-1).jsonData.aiContent = md.render(event.data)
|
|
|
|
|
- messages.value.at(-1).loading = false
|
|
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentid, props.userid || '', lang.lang)
|
|
|
|
|
+ streamController.value = result
|
|
|
|
|
+ console.log(result)
|
|
|
|
|
+ const content = await result.promise
|
|
|
|
|
+ messages.value.at(-1).jsonData.aiContent = content
|
|
|
|
|
+ console.log('event.data', content)
|
|
|
|
|
+ generate(messages.value.at(-1))
|
|
|
|
|
+
|
|
|
|
|
+ // chat_stream(prompt, agentid, props.userid || '', lang.lang, async (event) => {
|
|
|
|
|
+ // if (event.type === 'message') {
|
|
|
|
|
+ // messages.value.at(-1).jsonData.aiContent = md.render(event.data)
|
|
|
|
|
+ // messages.value.at(-1).loading = false
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else if (event.type === 'messageEnd') {
|
|
|
|
|
- messages.value.at(-1).jsonData.aiContent = md.render(event.data)
|
|
|
|
|
- console.log('event.data', event.data)
|
|
|
|
|
- generate(messages.value.at(-1))
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }, session_name.value, messages.value.at(-1).sourceFiles?.map(file => file.id).filter(Boolean)).then(controller => {
|
|
|
|
|
- streamController.value = controller
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
- chatLoading.value = false
|
|
|
|
|
- console.log('err', err)
|
|
|
|
|
- stopMessage()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else if (event.type === 'messageEnd') {
|
|
|
|
|
+ // messages.value.at(-1).jsonData.aiContent = md.render(event.data)
|
|
|
|
|
+ // console.log('event.data', event.data)
|
|
|
|
|
+ // generate(messages.value.at(-1))
|
|
|
|
|
+
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }, session_name.value, messages.value.at(-1).sourceFiles?.map(file => file.id).filter(Boolean)).then(controller => {
|
|
|
|
|
+ // streamController.value = controller
|
|
|
|
|
+ // }).catch(err => {
|
|
|
|
|
+ // chatLoading.value = false
|
|
|
|
|
+ // console.log('err', err)
|
|
|
|
|
+ // stopMessage()
|
|
|
|
|
+ // })
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -816,6 +865,14 @@ const generate = (message: ChatMessage) => {
|
|
|
slidesStore.updateSlide({ toolsArray: item.tools }, slide.id)
|
|
slidesStore.updateSlide({ toolsArray: item.tools }, slide.id)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ const firstPageWithTools = slidesStore.slides.findIndex((slide: any) =>
|
|
|
|
|
+ slide.toolsArray && slide.toolsArray.length > 0
|
|
|
|
|
+ )
|
|
|
|
|
+ if (firstPageWithTools !== -1) {
|
|
|
|
|
+ slidesStore.updateSlideIndex(firstPageWithTools)
|
|
|
|
|
+ mainStore.setChildPageState(true, slidesStore.slides[firstPageWithTools].toolsArray || [], firstPageWithTools || 0)
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|