|
@@ -661,32 +661,54 @@ const sendAction = async (action: string) => {
|
|
|
})
|
|
})
|
|
|
.filter(content => content.trim() !== '') || []
|
|
.filter(content => content.trim() !== '') || []
|
|
|
|
|
|
|
|
|
|
+ // 提取所有页面中 type 为 'image' 的元素的纯文本内容
|
|
|
|
|
+ const allImgContents = slidesStore.slides.flatMap((slide: any) => {
|
|
|
|
|
+ const elements = slide.elements || []
|
|
|
|
|
+ return elements
|
|
|
|
|
+ .filter((el: any) => el.type === 'image' && el.src?.includes('https'))
|
|
|
|
|
+ .map((el: any) => el.src.trim().replace('https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/', 'https://duimes0j49llm.cloudfront.net/'))
|
|
|
|
|
+ .filter((src: string) => !!src)
|
|
|
|
|
+ })
|
|
|
|
|
+ // 提取当前页面中 type 为 'image' 的元素 并且为链接
|
|
|
|
|
+ const imgContents = slidesStore.currentSlide?.elements
|
|
|
|
|
+ .filter((element: any) => element.type === 'image' && element.src.includes('https'))
|
|
|
|
|
+ .map((textElement: any) => textElement.src.replace('https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/', 'https://duimes0j49llm.cloudfront.net/'))
|
|
|
console.log('allTextContents', allTextContents)
|
|
console.log('allTextContents', allTextContents)
|
|
|
console.log('textContents', textContents)
|
|
console.log('textContents', textContents)
|
|
|
|
|
+ console.log('allImgContents', allImgContents)
|
|
|
|
|
+ console.log('imgContents', imgContents)
|
|
|
|
|
+
|
|
|
let prompt = ''
|
|
let prompt = ''
|
|
|
let agentid = agentid2.value
|
|
let agentid = agentid2.value
|
|
|
|
|
+ const imgUrls = []
|
|
|
|
|
|
|
|
|
|
|
|
|
if (gType.value === 'trigger_tool_recommend') {
|
|
if (gType.value === 'trigger_tool_recommend') {
|
|
|
agentid = agentid3.value
|
|
agentid = agentid3.value
|
|
|
|
|
+ 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}
|
|
#query: ${action}
|
|
|
`
|
|
`
|
|
|
}
|
|
}
|
|
|
else if (gType.value === 'trigger_batch_tool') {
|
|
else if (gType.value === 'trigger_batch_tool') {
|
|
|
agentid = agentid4.value
|
|
agentid = agentid4.value
|
|
|
|
|
+ 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}
|
|
#query: ${action}
|
|
|
`
|
|
`
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
|
|
+ imgUrls.push(...imgContents)
|
|
|
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}
|
|
#query: ${action}
|
|
|
`
|
|
`
|
|
|
}
|
|
}
|
|
@@ -699,7 +721,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)
|
|
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentid, props.userid || '', lang.lang, undefined, imgUrls)
|
|
|
streamController.value = result
|
|
streamController.value = result
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
const content = await result.promise
|
|
const content = await result.promise
|
|
@@ -731,7 +753,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)
|
|
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentid, props.userid || '', lang.lang, undefined, imgUrls)
|
|
|
streamController.value = result
|
|
streamController.value = result
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
const content = await result.promise
|
|
const content = await result.promise
|
|
@@ -775,7 +797,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)).then(controller => {
|
|
|
|
|
|
|
+ }, session_name.value, messages.value.at(-1).sourceFiles?.map(file => file.id).filter(Boolean), undefined, imgUrls).then(controller => {
|
|
|
streamController.value = controller
|
|
streamController.value = controller
|
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
|
chatLoading.value = false
|
|
chatLoading.value = false
|
|
@@ -1104,13 +1126,19 @@ const createTool = async (array: any[], tool: any, index: number, slide: any) =>
|
|
|
})
|
|
})
|
|
|
.filter(content => content.trim() !== '') || []
|
|
.filter(content => content.trim() !== '') || []
|
|
|
|
|
|
|
|
|
|
+ // 提取当前页面中 type 为 'image' 的元素 并且为链接
|
|
|
|
|
+ const imgContents = slidesStore.currentSlide?.elements
|
|
|
|
|
+ .filter((element: any) => element.type === 'image' && element.src.includes('https'))
|
|
|
|
|
+ .map((textElement: any) => textElement.src.replace('https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/', 'https://duimes0j49llm.cloudfront.net/'))
|
|
|
|
|
+
|
|
|
console.log('textContents', textContents)
|
|
console.log('textContents', textContents)
|
|
|
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}
|
|
#query: ${action}
|
|
|
`
|
|
`
|
|
|
- const result = chat_no_stream(prompt, agentid2.value, props.userid || '', lang.lang)
|
|
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentid2.value, props.userid || '', lang.lang, undefined, imgUrls)
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
const content = await result.promise
|
|
const content = await result.promise
|
|
|
console.log('👶 创建工具:', content)
|
|
console.log('👶 创建工具:', content)
|