|
@@ -51,6 +51,8 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { ref, onMounted, useTemplateRef, nextTick } from 'vue'
|
|
import { ref, onMounted, useTemplateRef, nextTick } from 'vue'
|
|
|
import { chat_no_stream, chat_stream, getAgentModel } from '@/tools/aiChat'
|
|
import { chat_no_stream, chat_stream, getAgentModel } from '@/tools/aiChat'
|
|
|
|
|
+import { useSlidesStore } from '@/store'
|
|
|
|
|
+import { lang } from '@/main'
|
|
|
import MarkdownIt from 'markdown-it'
|
|
import MarkdownIt from 'markdown-it'
|
|
|
|
|
|
|
|
interface ChatMessage {
|
|
interface ChatMessage {
|
|
@@ -145,15 +147,26 @@ const sendQuickAction = (action: string) => {
|
|
|
// }, 500)
|
|
// }, 500)
|
|
|
sendAction(action)
|
|
sendAction(action)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+import { v4 as uuidv4 } from 'uuid'
|
|
|
|
|
+const session_name = ref('')
|
|
|
|
|
+const slidesStore = useSlidesStore()
|
|
|
|
|
+const gType = ref('chat')
|
|
|
|
|
+
|
|
|
const sendAction = async (action: string) => {
|
|
const sendAction = async (action: string) => {
|
|
|
- const content = await chat_no_stream(action, agentid1.value, props.userid || '', 'zh-CN')
|
|
|
|
|
|
|
+ const content = await chat_no_stream(action, agentid1.value, props.userid || '', lang.lang)
|
|
|
console.log(content)
|
|
console.log(content)
|
|
|
// 渲染 Markdown 格式
|
|
// 渲染 Markdown 格式
|
|
|
const md = new MarkdownIt()
|
|
const md = new MarkdownIt()
|
|
|
const html = md.render(content)
|
|
const html = md.render(content)
|
|
|
messages.value.at(-1).aiContent = html
|
|
messages.value.at(-1).aiContent = html
|
|
|
|
|
|
|
|
- chat_stream(action, agentid1.value, props.userid || '', 'zh-CN', (event) => {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const prompt = `
|
|
|
|
|
+ #当前页面内容 ${JSON.stringify(slidesStore.currentSlide || '')}
|
|
|
|
|
+ #query: ${action}
|
|
|
|
|
+ `
|
|
|
|
|
+ chat_stream(prompt, agentid2.value, props.userid || '', lang.lang, (event) => {
|
|
|
if (event.type === 'message') {
|
|
if (event.type === 'message') {
|
|
|
messages.value.at(-1).aiContent = md.render(event.data)
|
|
messages.value.at(-1).aiContent = md.render(event.data)
|
|
|
|
|
|
|
@@ -168,13 +181,14 @@ const sendAction = async (action: string) => {
|
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
|
chatLoading.value = false
|
|
chatLoading.value = false
|
|
|
console.log('err', err)
|
|
console.log('err', err)
|
|
|
- })
|
|
|
|
|
|
|
+ }, session_name.value)
|
|
|
}
|
|
}
|
|
|
-const agentid1 = ref('4535eb8a-851b-4c47-a059-234f702d89c4')
|
|
|
|
|
-const agentid2 = ref('6c5b2386-f305-4062-bf53-125c0058fafa')
|
|
|
|
|
|
|
+const agentid1 = ref('cbb29b41-2a4a-4453-bf8d-357929ced4bd')// 判断意图
|
|
|
|
|
+const agentid2 = ref('f86aa63c-b7b7-4d03-9b37-b59f116d36f3')// 生成内容
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
|
|
+ session_name.value = uuidv4()
|
|
|
getAgentModel(agentid1.value)
|
|
getAgentModel(agentid1.value)
|
|
|
getAgentModel(agentid2.value)
|
|
getAgentModel(agentid2.value)
|
|
|
})
|
|
})
|