|
|
@@ -900,6 +900,19 @@ const generate = (message: ChatMessage) => {
|
|
|
slidesStore.updateSlide({ toolsArray: item.tools }, slide.id)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ for (let i = 0; i < slidesStore.slides.length; i++) {
|
|
|
+ const slide = slidesStore.slides[i]
|
|
|
+ if (slide.toolsArray && slide.toolsArray.length > 0) {
|
|
|
+ for (let j = 0; j < slide.toolsArray.length; j++) {
|
|
|
+ const tool = slide.toolsArray[j]
|
|
|
+ if (tool.url) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createTool(slide.toolsArray, tool, j, slide)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
const firstPageWithTools = slidesStore.slides.findIndex((slide: any) =>
|
|
|
slide.toolsArray && slide.toolsArray.length > 0
|
|
|
@@ -931,6 +944,84 @@ const generate = (message: ChatMessage) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const createTool = async (array: any[], tool: any, index: number, slide: any) => {
|
|
|
+ let action = ''
|
|
|
+ let type = 0
|
|
|
+ if (tool.tool_id === 'choice') {
|
|
|
+ action = lang.ssAiChatQuickAction1
|
|
|
+ type = 45
|
|
|
+ }
|
|
|
+ else if (tool.tool_id === 'qa') {
|
|
|
+ action = lang.ssAiChatQuickAction2
|
|
|
+ type = 15
|
|
|
+ }
|
|
|
+ else if (tool.tool_id === 'poll') {
|
|
|
+ action = lang.ssAiChatQuickAction6
|
|
|
+ type = 78
|
|
|
+ }
|
|
|
+ else if (tool.tool_id === 'photo') {
|
|
|
+ action = lang.ssAiChatQuickAction7
|
|
|
+ type = 79
|
|
|
+ }
|
|
|
+
|
|
|
+ const textContents = slide?.elements
|
|
|
+ .filter((element: any) => element.type === 'text' || (element.type === 'shape' && element.text && element.text.content))
|
|
|
+ .map((textElement: any) => {
|
|
|
+ if (textElement.type === 'shape') {
|
|
|
+ const tempElement = document.createElement('div')
|
|
|
+ tempElement.innerHTML = textElement.text.content
|
|
|
+ return tempElement.textContent || tempElement.innerText || ''
|
|
|
+ }
|
|
|
+ const tempElement = document.createElement('div')
|
|
|
+ tempElement.innerHTML = textElement.content
|
|
|
+ return tempElement.textContent || tempElement.innerText || ''
|
|
|
+ })
|
|
|
+ .filter(content => content.trim() !== '') || []
|
|
|
+
|
|
|
+ console.log('textContents', textContents)
|
|
|
+ const prompt = `
|
|
|
+ #课程标题(course_title): ${props.courseTitle || ''}
|
|
|
+ #当前页面内容(current_page_content): ${textContents.length > 0 ? textContents.join('\n') : '无文本内容'}
|
|
|
+ #query: ${action}
|
|
|
+ `
|
|
|
+ const result = chat_no_stream(prompt, agentid2.value, props.userid || '', lang.lang)
|
|
|
+ console.log(result)
|
|
|
+ const content = await result.promise
|
|
|
+ console.log('👶 创建工具:', content)
|
|
|
+
|
|
|
+ let jsonFormat = ''
|
|
|
+ if (tool.tool_id === 'choice') {
|
|
|
+ jsonFormat = `{"testCount":1,"testTitle":"","testJson":[{"id":"7de1fdb4-bec3-4324-8986-4623f838e3d7","type":"2","teststitle":"1+1?","checkList":["1","2","3"],"timuList":[],"answer":[1],"userAnswer":[],"explanation":"解析"}]}`
|
|
|
+ }
|
|
|
+ else if (tool.tool_id === 'qa') {
|
|
|
+ jsonFormat = `{"answerQ":"问题","answer":"","fileList":[],"imageList":[],"evaluationCriteria":"评价标准"}`
|
|
|
+ }
|
|
|
+ else if (tool.tool_id === 'poll') {
|
|
|
+ jsonFormat = `{"testCount":1,"testTitle":"","testJson":[{"id":"7de1fdb4-bec3-4324-8986-4623f838e3d7","type":"2","teststitle":"1+1?","checkList":["1","2","3"],"timuList":[],"answer":[],"userAnswer":[]}]}`
|
|
|
+ }
|
|
|
+ else if (tool.tool_id === 'photo') {
|
|
|
+ jsonFormat = `{"answerQ":"问题","answer":"","fileList":[]}`
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await chat_no_stream2([{
|
|
|
+ role: 'user',
|
|
|
+ content: `这是用户输入的内容:"${content}",根据用户输入的内容,生成json。输出一个json格式的回复,格式如下:${jsonFormat}。`,
|
|
|
+ }], { type: 'json_object' })
|
|
|
+
|
|
|
+ console.log(`${tool.tool_name}`, res)
|
|
|
+
|
|
|
+ const pageId = await setPageId(type, res)
|
|
|
+ const baseUrl = setUrl()
|
|
|
+ const url = `${baseUrl}/pbl-teacher-table/dist/workPage.html#/setWorkPage?id=${pageId}&type=${type}&userid=${props.userid || ''}`
|
|
|
+ array[index].url = url
|
|
|
+ setTool(slide, array)
|
|
|
+}
|
|
|
+
|
|
|
+const setTool = (slide: any, toolsArray: any[]) => {
|
|
|
+ slidesStore.updateSlide({ toolsArray: toolsArray }, slide.id)
|
|
|
+ console.log(slide)
|
|
|
+}
|
|
|
+
|
|
|
const setPageId = async (tool: any, json: any) => {
|
|
|
const res = await getWorkPageId({
|
|
|
userid: props.userid || '',
|
|
|
@@ -1104,6 +1195,19 @@ onMounted(() => {
|
|
|
getAgentModel(agentid3.value)
|
|
|
getAgentModel(agentid4.value)
|
|
|
getAgentModel(agentid5.value)
|
|
|
+
|
|
|
+ for (let i = 0; i < slidesStore.slides.length; i++) {
|
|
|
+ const slide = slidesStore.slides[i]
|
|
|
+ if (slide.toolsArray && slide.toolsArray.length > 0) {
|
|
|
+ for (let j = 0; j < slide.toolsArray.length; j++) {
|
|
|
+ const tool = slide.toolsArray[j]
|
|
|
+ if (tool.url) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createTool(slide.toolsArray, tool, j, slide)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
</script>
|
|
|
|