|
@@ -223,6 +223,8 @@ import message from '@/utils/message'
|
|
|
import AiWeb from './aiWeb.vue'
|
|
import AiWeb from './aiWeb.vue'
|
|
|
import katex from 'katex'
|
|
import katex from 'katex'
|
|
|
import 'katex/dist/katex.min.css'
|
|
import 'katex/dist/katex.min.css'
|
|
|
|
|
+import fileidArray from './fileid.js'
|
|
|
|
|
+
|
|
|
|
|
|
|
|
interface ChatMessage {
|
|
interface ChatMessage {
|
|
|
uid?: string
|
|
uid?: string
|
|
@@ -681,16 +683,20 @@ const sendAction = async (action: string) => {
|
|
|
let prompt = ''
|
|
let prompt = ''
|
|
|
let agentid = agentid2.value
|
|
let agentid = agentid2.value
|
|
|
const imgUrls = []
|
|
const imgUrls = []
|
|
|
-
|
|
|
|
|
|
|
+ const fileid = []
|
|
|
|
|
+ if (lang.lang === 'hk') {
|
|
|
|
|
+ fileid.push(...fileidArray)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (gType.value === 'trigger_tool_recommend') {
|
|
if (gType.value === 'trigger_tool_recommend') {
|
|
|
agentid = agentid3.value
|
|
agentid = agentid3.value
|
|
|
imgUrls.push(...allImgContents)
|
|
imgUrls.push(...allImgContents)
|
|
|
|
|
+
|
|
|
prompt = `
|
|
prompt = `
|
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
|
#当前页面内容(all_pages_content): ${allTextContents.length > 0 ? allTextContents.join('\n') : '无文本内容'}
|
|
#当前页面内容(all_pages_content): ${allTextContents.length > 0 ? allTextContents.join('\n') : '无文本内容'}
|
|
|
- ${imgUrls.length ? '识别图片内容' : ''}
|
|
|
|
|
- #query: ${action}
|
|
|
|
|
|
|
+ ${imgUrls.length ? '识别图片内容' : ''}
|
|
|
|
|
+ #query: ${action} ${fileid.length > 0 ? `可以分析并读取知识库有用的内容结合一下再回答` : ''}
|
|
|
`
|
|
`
|
|
|
}
|
|
}
|
|
|
else if (gType.value === 'trigger_batch_tool') {
|
|
else if (gType.value === 'trigger_batch_tool') {
|
|
@@ -699,8 +705,8 @@ const sendAction = async (action: string) => {
|
|
|
prompt = `
|
|
prompt = `
|
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
|
#当前页面内容(all_pages_content): ${allTextContents.length > 0 ? allTextContents.join('\n') : '无文本内容'}
|
|
#当前页面内容(all_pages_content): ${allTextContents.length > 0 ? allTextContents.join('\n') : '无文本内容'}
|
|
|
- ${imgUrls.length ? '识别图片内容' : ''}
|
|
|
|
|
- #query: ${action}
|
|
|
|
|
|
|
+ ${imgUrls.length ? '识别图片内容' : ''}
|
|
|
|
|
+ #query: ${action} ${fileid.length > 0 ? `可以分析并读取知识库有用的内容结合一下再回答` : ''}
|
|
|
`
|
|
`
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
@@ -708,8 +714,8 @@ const sendAction = async (action: string) => {
|
|
|
prompt = `
|
|
prompt = `
|
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
|
#当前页面内容(current_page_content): ${textContents.length > 0 ? textContents.join('\n') : '无文本内容'}
|
|
#当前页面内容(current_page_content): ${textContents.length > 0 ? textContents.join('\n') : '无文本内容'}
|
|
|
- ${imgUrls.length ? '识别图片内容' : ''}
|
|
|
|
|
- #query: ${action}
|
|
|
|
|
|
|
+ ${imgUrls.length ? '识别图片内容' : ''}
|
|
|
|
|
+ #query: ${action} ${fileid.length > 0 ? `可以分析并读取知识库有用的内容结合一下再回答` : ''}
|
|
|
`
|
|
`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -721,7 +727,7 @@ const sendAction = async (action: string) => {
|
|
|
console.log('loadingDots.value', loadingDots.value)
|
|
console.log('loadingDots.value', loadingDots.value)
|
|
|
console.log('messages.value.at(-1).aiContent', messages.value.at(-1).aiContent)
|
|
console.log('messages.value.at(-1).aiContent', messages.value.at(-1).aiContent)
|
|
|
}, 500)
|
|
}, 500)
|
|
|
- const result = chat_no_stream(prompt, agentid, props.userid || '', lang.lang, undefined, imgUrls)
|
|
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentid, props.userid || '', lang.lang, undefined, imgUrls, fileid)
|
|
|
streamController.value = result
|
|
streamController.value = result
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
const content = await result.promise
|
|
const content = await result.promise
|
|
@@ -753,7 +759,7 @@ const sendAction = async (action: string) => {
|
|
|
}
|
|
}
|
|
|
else if (gType.value === 'generate_interactive_web') {
|
|
else if (gType.value === 'generate_interactive_web') {
|
|
|
agentid = agentid5.value
|
|
agentid = agentid5.value
|
|
|
- const result = chat_no_stream(prompt, agentid, props.userid || '', lang.lang, undefined, imgUrls)
|
|
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentid, props.userid || '', lang.lang, undefined, imgUrls, fileid)
|
|
|
streamController.value = result
|
|
streamController.value = result
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
const content = await result.promise
|
|
const content = await result.promise
|
|
@@ -783,7 +789,14 @@ const sendAction = async (action: string) => {
|
|
|
// })
|
|
// })
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if (messages.value.at(-1).sourceFiles?.map(file => file.id).filter(Boolean).length) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ fileid.push(...messages.value.at(-1).sourceFiles?.map(file => file.id).filter(Boolean))
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (error) {
|
|
|
|
|
+ console.log('error', error)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
chat_stream(prompt, agentid, props.userid || '', lang.lang, (event) => {
|
|
chat_stream(prompt, agentid, props.userid || '', lang.lang, (event) => {
|
|
|
if (event.type === 'message') {
|
|
if (event.type === 'message') {
|
|
|
messages.value.at(-1).aiContent = md.render(katexZ(event.data))
|
|
messages.value.at(-1).aiContent = md.render(katexZ(event.data))
|
|
@@ -797,7 +810,7 @@ const sendAction = async (action: string) => {
|
|
|
chatLoading.value = false
|
|
chatLoading.value = false
|
|
|
prevChatResult()
|
|
prevChatResult()
|
|
|
}
|
|
}
|
|
|
- }, session_name.value, messages.value.at(-1).sourceFiles?.map(file => file.id).filter(Boolean), undefined, imgUrls).then(controller => {
|
|
|
|
|
|
|
+ }, session_name.value, fileid, undefined, imgUrls).then(controller => {
|
|
|
streamController.value = controller
|
|
streamController.value = controller
|
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
|
chatLoading.value = false
|
|
chatLoading.value = false
|
|
@@ -1112,6 +1125,11 @@ const createTool = async (array: any[], tool: any, index: number, slide: any) =>
|
|
|
type = 84
|
|
type = 84
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const fileid = []
|
|
|
|
|
+ if (lang.lang === 'hk') {
|
|
|
|
|
+ fileid.push(...fileidArray)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const textContents = slide?.elements
|
|
const textContents = slide?.elements
|
|
|
.filter((element: any) => element.type === 'text' || (element.type === 'shape' && element.text && element.text.content))
|
|
.filter((element: any) => element.type === 'text' || (element.type === 'shape' && element.text && element.text.content))
|
|
|
.map((textElement: any) => {
|
|
.map((textElement: any) => {
|
|
@@ -1135,10 +1153,10 @@ const createTool = async (array: any[], tool: any, index: number, slide: any) =>
|
|
|
const prompt = `
|
|
const prompt = `
|
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
#课程标题(course_title): ${props.courseTitle || ''}
|
|
|
#当前页面内容(current_page_content): ${textContents.length > 0 ? textContents.join('\n') : '无文本内容'}
|
|
#当前页面内容(current_page_content): ${textContents.length > 0 ? textContents.join('\n') : '无文本内容'}
|
|
|
- ${imgContents.length ? '识别图片内容' : ''}
|
|
|
|
|
- #query: ${action}
|
|
|
|
|
|
|
+ ${imgContents.length ? '识别图片内容' : ''}
|
|
|
|
|
+ #query: ${action} ${fileid.length > 0 ? `可以分析并读取知识库有用的内容结合一下再回答` : ''}
|
|
|
`
|
|
`
|
|
|
- const result = chat_no_stream(prompt, agentid2.value, props.userid || '', lang.lang, undefined, imgUrls)
|
|
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentid2.value, props.userid || '', lang.lang, undefined, imgContents, fileid)
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
const content = await result.promise
|
|
const content = await result.promise
|
|
|
console.log('👶 创建工具:', content)
|
|
console.log('👶 创建工具:', content)
|