|
@@ -294,6 +294,8 @@ const quickActions = [
|
|
|
lang.ssAiChatQuickAction6,
|
|
lang.ssAiChatQuickAction6,
|
|
|
lang.ssAiChatQuickAction7,
|
|
lang.ssAiChatQuickAction7,
|
|
|
lang.ssAiChatQuickAction4,
|
|
lang.ssAiChatQuickAction4,
|
|
|
|
|
+ lang.ssAiChatQuickAction8,
|
|
|
|
|
+ lang.ssAiChatQuickAction9,
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
// 监听输入变化,当输入"/"时显示快捷操作
|
|
// 监听输入变化,当输入"/"时显示快捷操作
|
|
@@ -473,7 +475,7 @@ const sendAction = async (action: string) => {
|
|
|
gType.value = 'chat'
|
|
gType.value = 'chat'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // generate_qa // generate_choice_question // generate_photo // generate_poll
|
|
|
|
|
|
|
+ // generate_qa // generate_choice_question // generate_take_photo // generate_poll
|
|
|
if (gType.value !== 'chat' && gType.value !== 'generate_interactive_web' && gType.value !== 'trigger_batch_tool') {
|
|
if (gType.value !== 'chat' && gType.value !== 'generate_interactive_web' && gType.value !== 'trigger_batch_tool') {
|
|
|
messages.value.at(-1).jsonData = {
|
|
messages.value.at(-1).jsonData = {
|
|
|
gType: gType.value,
|
|
gType: gType.value,
|
|
@@ -769,7 +771,7 @@ const sendAction = async (action: string) => {
|
|
|
import useCreateElement from '@/hooks/useCreateElement'
|
|
import useCreateElement from '@/hooks/useCreateElement'
|
|
|
import useSlideHandler from '@/hooks/useSlideHandler'
|
|
import useSlideHandler from '@/hooks/useSlideHandler'
|
|
|
const { createSlide } = useSlideHandler()
|
|
const { createSlide } = useSlideHandler()
|
|
|
-const { createFrameElement } = useCreateElement()
|
|
|
|
|
|
|
+const { createFrameElement, createImageElement } = useCreateElement()
|
|
|
|
|
|
|
|
|
|
|
|
|
const katexZ = (str) => {
|
|
const katexZ = (str) => {
|
|
@@ -826,7 +828,7 @@ const setUrl = () => {
|
|
|
return url
|
|
return url
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const generate = (message: ChatMessage) => {
|
|
|
|
|
|
|
+const generate = async (message: ChatMessage) => {
|
|
|
if (message.gLoading || message.jsonData?.isGenerate) {
|
|
if (message.gLoading || message.jsonData?.isGenerate) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -894,7 +896,7 @@ const generate = (message: ChatMessage) => {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
- else if (message.jsonData?.gType === 'generate_photo') {
|
|
|
|
|
|
|
+ else if (message.jsonData?.gType === 'generate_take_photo') {
|
|
|
console.log(message.jsonData?.gType)
|
|
console.log(message.jsonData?.gType)
|
|
|
const prompt = [
|
|
const prompt = [
|
|
|
{
|
|
{
|
|
@@ -915,6 +917,52 @@ const generate = (message: ChatMessage) => {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (message.jsonData?.gType === 'generate_file') {
|
|
|
|
|
+ console.log(message.jsonData?.gType)
|
|
|
|
|
+ const prompt = [
|
|
|
|
|
+ {
|
|
|
|
|
+ role: 'user',
|
|
|
|
|
+ content: `这是用户输入的内容:“${message.aiContent}”,根据用户输入的内容,生成文件上传的json。输出一个json格式的回复,格式如下:{"answerQ":"问题","answer":"","fileList":[]}。`, // ,"imageList":[],"evaluationCriteria":"评价标准" 输出语言为${lang.lang === 'en' ? '英文' : lang.lang === 'hk' ? '繁体中文' : '简体中文'}
|
|
|
|
|
+ },
|
|
|
|
|
+ ]
|
|
|
|
|
+ chat_no_stream2(prompt, { type: 'json_object' }).then((res: any) => {
|
|
|
|
|
+ console.log('文件上传', JSON.parse(res))
|
|
|
|
|
+ gType.value = 'chat'
|
|
|
|
|
+ setPageId(84, res).then(res => {
|
|
|
|
|
+ const baseUrl = setUrl()
|
|
|
|
|
+ const url = `${baseUrl}/pbl-teacher-table/dist/workPage.html#/setWorkPage?id=${res}&type=${84}&userid=${props.userid || ''}`
|
|
|
|
|
+ createSlide()
|
|
|
|
|
+ createFrameElement(url, 84)
|
|
|
|
|
+ message.gLoading = false
|
|
|
|
|
+ message.jsonData.isGenerate = true
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (message.jsonData?.gType === 'generate_image') {
|
|
|
|
|
+ console.log(message.jsonData?.gType)
|
|
|
|
|
+ const prompt = `${message.aiContent} 根据用户的内容,生成图片`
|
|
|
|
|
+ const result = chat_no_stream(prompt, agentidPhoto.value, props.userid || '', lang.lang)
|
|
|
|
|
+ console.log('图片', result)
|
|
|
|
|
+ const content = await result.promise
|
|
|
|
|
+ console.log('event.data', content)
|
|
|
|
|
+ // 从content中提取图片链接
|
|
|
|
|
+ const urlMatch = content.match(/\[.*?\]\((https?:\/\/.*?)\)/)
|
|
|
|
|
+ const imageUrl = urlMatch ? urlMatch[1] : ''
|
|
|
|
|
+
|
|
|
|
|
+ // 判断当前页面是否是工具页(含frame元素)
|
|
|
|
|
+ const isToolPage = (currentSlide.value?.elements || []).some((el: any) => el.type === 'frame')
|
|
|
|
|
+ // 如果当前页不是工具页则直接加图片,是工具页则新建页面再加图片
|
|
|
|
|
+ if (!isToolPage) {
|
|
|
|
|
+ createImageElement(imageUrl)
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ createSlide()
|
|
|
|
|
+ createImageElement(imageUrl)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ message.gLoading = false
|
|
|
|
|
+ message.jsonData.isGenerate = true
|
|
|
|
|
+ }
|
|
|
else if (message.jsonData?.gType === 'trigger_batch_tool') {
|
|
else if (message.jsonData?.gType === 'trigger_batch_tool') {
|
|
|
console.log(message.jsonData?.gType)
|
|
console.log(message.jsonData?.gType)
|
|
|
const prompt = [
|
|
const prompt = [
|
|
@@ -1009,6 +1057,10 @@ const createTool = async (array: any[], tool: any, index: number, slide: any) =>
|
|
|
action = lang.ssAiChatQuickAction7
|
|
action = lang.ssAiChatQuickAction7
|
|
|
type = 79
|
|
type = 79
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (tool.tool_id === 'file') {
|
|
|
|
|
+ action = lang.ssAiChatQuickAction9
|
|
|
|
|
+ type = 84
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
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))
|
|
@@ -1048,6 +1100,9 @@ const createTool = async (array: any[], tool: any, index: number, slide: any) =>
|
|
|
else if (tool.tool_id === 'photo') {
|
|
else if (tool.tool_id === 'photo') {
|
|
|
jsonFormat = `{"answerQ":"问题","answer":"","fileList":[]}`
|
|
jsonFormat = `{"answerQ":"问题","answer":"","fileList":[]}`
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (tool.tool_id === 'file') {
|
|
|
|
|
+ jsonFormat = `{"answerQ":"问题","answer":"","fileList":[]}`
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
const res = await chat_no_stream2([{
|
|
const res = await chat_no_stream2([{
|
|
|
role: 'user',
|
|
role: 'user',
|
|
@@ -1127,6 +1182,7 @@ const agentid2 = ref('f86aa63c-b7b7-4d03-9b37-b59f116d36f3')// 生成内容
|
|
|
const agentid3 = ref('caaa43ab-41a5-466a-94bc-74e0c9265068')// 互动工具推荐
|
|
const agentid3 = ref('caaa43ab-41a5-466a-94bc-74e0c9265068')// 互动工具推荐
|
|
|
const agentid4 = ref('b41bc650-9861-468c-a624-b52269dfff22')// 批量生成工具
|
|
const agentid4 = ref('b41bc650-9861-468c-a624-b52269dfff22')// 批量生成工具
|
|
|
const agentid5 = ref('939d28ef-3a1b-442b-871f-3894eb67ac9c')// 互动网页
|
|
const agentid5 = ref('939d28ef-3a1b-442b-871f-3894eb67ac9c')// 互动网页
|
|
|
|
|
+const agentidPhoto = ref('2adb7966-86a3-42b4-a9fb-7439635fb28b')// 互动图片
|
|
|
|
|
|
|
|
const isQuickActions = ref<string[]>([])
|
|
const isQuickActions = ref<string[]>([])
|
|
|
const toggleQuickActions = (section: string) => {
|
|
const toggleQuickActions = (section: string) => {
|
|
@@ -1241,6 +1297,7 @@ onMounted(() => {
|
|
|
getAgentModel(agentid3.value)
|
|
getAgentModel(agentid3.value)
|
|
|
getAgentModel(agentid4.value)
|
|
getAgentModel(agentid4.value)
|
|
|
getAgentModel(agentid5.value)
|
|
getAgentModel(agentid5.value)
|
|
|
|
|
+ getAgentModel(agentidPhoto.value)
|
|
|
|
|
|
|
|
for (let i = 0; i < slidesStore.slides.length; i++) {
|
|
for (let i = 0; i < slidesStore.slides.length; i++) {
|
|
|
const slide = slidesStore.slides[i]
|
|
const slide = slidesStore.slides[i]
|