From 21e5352fe666e8be0b3aa7ad5a3115038ee9a5b2 Mon Sep 17 00:00:00 2001 From: tmaog Date: Fri, 15 Nov 2024 18:09:29 +0100 Subject: [PATCH 01/17] fix: nodeId bug and filename display fix --- .../Forms/Fields/UploadDownloadField.tsx | 85 ++++++++++++------- 1 file changed, 55 insertions(+), 30 deletions(-) diff --git a/src/components/Forms/Fields/UploadDownloadField.tsx b/src/components/Forms/Fields/UploadDownloadField.tsx index bbcd100..143bb9d 100644 --- a/src/components/Forms/Fields/UploadDownloadField.tsx +++ b/src/components/Forms/Fields/UploadDownloadField.tsx @@ -8,29 +8,47 @@ import { useToast, VStack, } from '@chakra-ui/react'; +import { AxiosResponse } from 'axios'; import { useEffect, useState } from 'react'; import { API } from '../../../data/api'; import useStore from '../../../store'; + const FileUploadDownload = () => { const [file, setFile] = useState(); - const [nodeId, setNodeId] = useState('1'); + const [nodeId, setNodeId] = useState(); + const [filename, setFilename] = useState(); const toast = useToast(); // Gestione del file selezionato const handleFileChange = (event: any) => { setFile(event.target.files[0]); }; + const { getSelectedElement } = useStore((store) => ({ + getSelectedElement: store.getSelectedElement, + })); + useEffect(() => { - setNodeId(useStore.getState().getSelectedNode()?._id || '1'); - console.log(nodeId); - API.downloadFile({ nodeId }).then((response) => { - if (response.data) setFile(response.data); - }); + const selectedElement = getSelectedElement(); + if (!selectedElement) return; + setNodeId(selectedElement._id); + API.downloadFile({ nodeId: selectedElement._id }) + .then((response) => { + if (response.data) { + const contentDisposition = response.headers["content-disposition"]; + const filename = contentDisposition + ?.split("filename=")?.[1] + ?.replace(/"/g, ""); + setFilename(filename); + } + }) + .catch((error: AxiosResponse) => { + console.log(error); + }); }, []); - // Funzione per l'upload const handleUpload = async () => { + if(!nodeId) return if (!file) { toast({ title: 'Seleziona un file e inserisci un ID nodo.', @@ -56,13 +74,13 @@ const FileUploadDownload = () => { file: formData, }).then((resp) => toast({ - title: 'File caricato con successo.\n' + resp.data, + title: 'File uploaded successfully.\n' + resp.data, status: 'success', }) ); } catch (error) { toast({ - title: 'Errore durante il caricamento del file.', + title: "File's upload failed", status: 'error', }); } @@ -70,26 +88,33 @@ const FileUploadDownload = () => { // Funzione per il download const handleDownload = async () => { - try { - const response = await API.downloadFile({ nodeId }); - - const url = window.URL.createObjectURL(new Blob([response.data])); - const link = document.createElement('a'); - link.href = url; - console.log(response.data.filename); - - console.log(response.data); - link.setAttribute( - 'download', - response.data.filename || 'uploadedFile.pdf' - ); - - document.body.appendChild(link); - link.click(); - - link.remove(); - window.URL.revokeObjectURL(url); - } catch (error) { + if(!nodeId) return + try { + const response = await API.downloadFile({ nodeId }); + const contentDisposition = response.headers["content-disposition"]; + const filename = contentDisposition + ?.split("filename=")?.[1] + ?.replace(/"/g, ""); + const url = window.URL.createObjectURL(new Blob([response.data])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute( + 'download', + filename || 'uploadedFile.pdf' + ); + document.body.appendChild(link); + link.click(); + link.remove(); + window.URL.revokeObjectURL(url); + + return; + } catch (error: any) { + console.log(error); + if (error.status == 304) + toast({ + title: 'There are no file for this node', + status: 'info', + }); toast({ title: 'Errore durante il download del file.', status: 'error' }); } }; @@ -108,7 +133,7 @@ const FileUploadDownload = () => { Scarica File - + ); }; From 51edcf4a62b7c860ba7eced19e60840f0c688a2c Mon Sep 17 00:00:00 2001 From: tmaog Date: Fri, 15 Nov 2024 18:10:12 +0100 Subject: [PATCH 02/17] fix: bug fix --- .../Forms/Fields/UploadDownloadField.tsx | 58 +++++++++---------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/src/components/Forms/Fields/UploadDownloadField.tsx b/src/components/Forms/Fields/UploadDownloadField.tsx index 143bb9d..4eb22e3 100644 --- a/src/components/Forms/Fields/UploadDownloadField.tsx +++ b/src/components/Forms/Fields/UploadDownloadField.tsx @@ -13,7 +13,6 @@ import { useEffect, useState } from 'react'; import { API } from '../../../data/api'; import useStore from '../../../store'; - const FileUploadDownload = () => { const [file, setFile] = useState(); const [nodeId, setNodeId] = useState(); @@ -29,16 +28,16 @@ const FileUploadDownload = () => { })); useEffect(() => { - const selectedElement = getSelectedElement(); + const selectedElement = getSelectedElement(); if (!selectedElement) return; setNodeId(selectedElement._id); API.downloadFile({ nodeId: selectedElement._id }) .then((response) => { if (response.data) { - const contentDisposition = response.headers["content-disposition"]; + const contentDisposition = response.headers['content-disposition']; const filename = contentDisposition - ?.split("filename=")?.[1] - ?.replace(/"/g, ""); + ?.split('filename=')?.[1] + ?.replace(/"/g, ''); setFilename(filename); } }) @@ -48,7 +47,7 @@ const FileUploadDownload = () => { }, []); // Funzione per l'upload const handleUpload = async () => { - if(!nodeId) return + if (!nodeId) return; if (!file) { toast({ title: 'Seleziona un file e inserisci un ID nodo.', @@ -88,33 +87,30 @@ const FileUploadDownload = () => { // Funzione per il download const handleDownload = async () => { - if(!nodeId) return - try { - const response = await API.downloadFile({ nodeId }); - const contentDisposition = response.headers["content-disposition"]; - const filename = contentDisposition - ?.split("filename=")?.[1] - ?.replace(/"/g, ""); - const url = window.URL.createObjectURL(new Blob([response.data])); - const link = document.createElement('a'); - link.href = url; - link.setAttribute( - 'download', - filename || 'uploadedFile.pdf' - ); - document.body.appendChild(link); - link.click(); - link.remove(); - window.URL.revokeObjectURL(url); - + if (!nodeId) return; + try { + const response = await API.downloadFile({ nodeId }); + const contentDisposition = response.headers['content-disposition']; + const filename = contentDisposition + ?.split('filename=')?.[1] + ?.replace(/"/g, ''); + const url = window.URL.createObjectURL(new Blob([response.data])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', filename || 'uploadedFile.pdf'); + document.body.appendChild(link); + link.click(); + link.remove(); + window.URL.revokeObjectURL(url); + return; } catch (error: any) { - console.log(error); - if (error.status == 304) - toast({ - title: 'There are no file for this node', - status: 'info', - }); + console.log(error); + if (error.status == 304) + toast({ + title: 'There are no file for this node', + status: 'info', + }); toast({ title: 'Errore durante il download del file.', status: 'error' }); } }; From 4992ccb134c48947df6ca7b6c022047322af98a6 Mon Sep 17 00:00:00 2001 From: tmaog Date: Sat, 16 Nov 2024 15:42:07 +0100 Subject: [PATCH 03/17] fix: refactoring ai api into backend --- src/data/api.ts | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/data/api.ts b/src/data/api.ts index f132484..5ba614e 100644 --- a/src/data/api.ts +++ b/src/data/api.ts @@ -50,20 +50,6 @@ const axiosProgress = axiosCreate.create({ }, }); -const AIAPIGeneration = axiosCreate.create({ - baseURL: 'https://skapi.polyglot-edu.com', - headers: { - 'Content-Type': 'application/json', - withCredentials: true, - Access: '*', - ApiKey: process.env.APIKEY, - SetupModel: - '{"secretKey": "' + - process.env.SETUPMODEL + - '","modelName": "gpt35Turbo","endpoint": "https://ai4edu.openai.azure.com/"}', - }, -}); - const axiosPapyGame = axiosCreate.create({ baseURL: 'https://papygame.tech/api/v1', headers: { @@ -412,36 +398,36 @@ export const API = { }, analyseMaterial: (body: AnalyseType): Promise => { - return AIAPIGeneration.post<{}, AxiosResponse, {}>( - `/MaterialAnalyser/analyseMaterial`, + return axios.post<{}, AxiosResponse, {}>( + `/api/openai/MaterialAnalyser`, body ); }, generateLO: (body: LOType): Promise => { - return AIAPIGeneration.post<{}, AxiosResponse, {}>( - `/LearningObjectiveGenerator/generateLearningObjective`, + return axios.post<{}, AxiosResponse, {}>( + `/api/openai/LearningObjectiveGenerator`, body ); }, generateMaterial: (body: MaterialType): Promise => { - return AIAPIGeneration.post<{}, AxiosResponse, {}>( - `/MaterialGenerator/generatematerial`, + return axios.post<{}, AxiosResponse, {}>( + `/api/openai/MaterialGenerator`, body ); }, summarize: (body: SummarizeType): Promise => { - return AIAPIGeneration.post<{}, AxiosResponse, {}>( - `/Summarizer/summarize`, + return axios.post<{}, AxiosResponse, {}>( + `/api/openai/Summarizer`, body ); }, generateNewExercise: (body: AIExerciseType): Promise => { - return AIAPIGeneration.post<{}, AxiosResponse, {}>( - `/ActivityGenerator/generateActivity`, + return axios.post<{}, AxiosResponse, {}>( + `/api/openai/ActivityGenerator`, body ); }, From 1017a66b372641738bbc60edf6c50f808f6a9b9b Mon Sep 17 00:00:00 2001 From: tmaog Date: Sat, 16 Nov 2024 15:42:51 +0100 Subject: [PATCH 04/17] fix: bug --- src/components/Modals/AIToolModal.tsx | 51 ++++++++++++++------------- src/data/api.ts | 6 +--- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/components/Modals/AIToolModal.tsx b/src/components/Modals/AIToolModal.tsx index 3c75170..dbbfc7c 100644 --- a/src/components/Modals/AIToolModal.tsx +++ b/src/components/Modals/AIToolModal.tsx @@ -136,6 +136,7 @@ const AIToolModal = ({ const response: AxiosResponse = await API.analyseMaterial({ material: sourceMaterial, }); + console.log(response); setTitle(response.data.Title); setLanguage(response.data.Language); setMacroSubject(response.data.MacroSubject); @@ -144,6 +145,7 @@ const AIToolModal = ({ setScreen1(false); setScreen2(true); } catch (error: any) { + console.log(error); if ((error as Error).name === 'SyntaxError') { toast({ title: 'Invalid syntax', @@ -155,36 +157,37 @@ const AIToolModal = ({ }); return; } - if (error.response.status) { - if (error.response.status == 500) - toast({ - title: 'Material Error', - description: - 'We are sorry, the resource is not analyzable, try with different material. Do not provide pages that are too long (e.g. Wikipedia pages) or too short, as they can not be analyzed correctly', - status: 'error', - duration: 5000, - position: 'bottom-left', - isClosable: true, - }); - else if (error.response.status != 200) + if (error.response) + if (error.response.status) { + if (error.response.status == 500) + toast({ + title: 'Material Error', + description: + 'We are sorry, the resource is not analyzable, try with different material. Do not provide pages that are too long (e.g. Wikipedia pages) or too short, as they can not be analyzed correctly', + status: 'error', + duration: 5000, + position: 'bottom-left', + isClosable: true, + }); + else if (error.response.status != 200) + toast({ + title: 'AI API Error', + description: + 'Internal Server error, try again. If the error persists try change material.', + status: 'error', + duration: 5000, + position: 'bottom-left', + isClosable: true, + }); + } else toast({ - title: 'AI API Error', - description: - 'Internal Server error, try again. If the error persists try change material.', + title: 'Generic Error', + description: 'Try later ' + (error as Error), status: 'error', duration: 5000, position: 'bottom-left', isClosable: true, }); - } else - toast({ - title: 'Generic Error', - description: 'Try later ' + (error as Error), - status: 'error', - duration: 5000, - position: 'bottom-left', - isClosable: true, - }); } finally { setGeneratingLoading(false); } diff --git a/src/data/api.ts b/src/data/api.ts index 5ba614e..721e857 100644 --- a/src/data/api.ts +++ b/src/data/api.ts @@ -20,7 +20,6 @@ import { } from '../types/polyglotElements/AIGenerativeTypes/AIGenerativeTypes'; import { ConceptMap } from '../types/polyglotElements/concept/Conceptmap'; import { - PapyAssignment, PapyAssignmentAPI, PapyProject, } from '../types/polyglotElements/PapyrusTypes/PapyrusTypes'; @@ -419,10 +418,7 @@ export const API = { }, summarize: (body: SummarizeType): Promise => { - return axios.post<{}, AxiosResponse, {}>( - `/api/openai/Summarizer`, - body - ); + return axios.post<{}, AxiosResponse, {}>(`/api/openai/Summarizer`, body); }, generateNewExercise: (body: AIExerciseType): Promise => { From 567d2eac930e4db13e721d2f1a69eeae6cc855b0 Mon Sep 17 00:00:00 2001 From: tmaog Date: Sun, 17 Nov 2024 23:49:41 +0100 Subject: [PATCH 05/17] fix: bug --- src/components/Modals/AIToolModal.tsx | 44 +++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/Modals/AIToolModal.tsx b/src/components/Modals/AIToolModal.tsx index dbbfc7c..8d29300 100644 --- a/src/components/Modals/AIToolModal.tsx +++ b/src/components/Modals/AIToolModal.tsx @@ -134,7 +134,7 @@ const AIToolModal = ({ throw ': no text given'; } const response: AxiosResponse = await API.analyseMaterial({ - material: sourceMaterial, + "material": sourceMaterial, }); console.log(response); setTitle(response.data.Title); @@ -265,9 +265,9 @@ const AIToolModal = ({ if (!topicGen) throw ': No topic generated'; setGeneratingLoading(true); const response: AxiosResponse = await API.generateLO({ - Topic: topicGen[topicIndex].Topic, - Level: level, - Context: '', + "Topic": topicGen[topicIndex].Topic, + "Level": level, + "Context": '', }); setChoices([ response.data.Remembering[0], @@ -396,20 +396,20 @@ const AIToolModal = ({ setGeneratingLoading(true); if (!topicGen) throw ': no topic generated'; const response: AxiosResponse = await API.generateNewExercise({ - macroSubject: macroSubjectGen, - title: titleGen, - level: level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy - typeOfActivity: exerciseType, //0=fill_the_gap, 1=question, 4=choice, - learningObjective: choices[choiceIndex], - bloomLevel: Math.round(choiceIndex / 2), //0=Remembering, 1=Understanding, 2=Applying, 3=Analyzing, 4=Evaluating, 5=Creating - language: language, - material: sourceMaterial, - correctAnswersNumber: ca_n, - distractorsNumber: da_n, - easilyDiscardableDistractorsNumber: eda_n, - assignmentType: topicGen[topicIndex].Type, //0=theoretical, 1=code, 2=problem_resolution, - topic: topicGen[topicIndex].Topic, - temperature: 0.2, + "macroSubject": macroSubjectGen, + "title": titleGen, + "level": level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy + "typeOfActivity": exerciseType, //0=fill_the_gap, 1=question, 4=choice, + "learningObjective": choices[choiceIndex], + "bloomLevel": Math.round(choiceIndex / 2), //0=Remembering, 1=Understanding, 2=Applying, 3=Analyzing, 4=Evaluating, 5=Creating + "language": language, + "material": sourceMaterial, + "correctAnswersNumber": ca_n, + "distractorsNumber": da_n, + "easilyDiscardableDistractorsNumber": eda_n, + "assignmentType": topicGen[topicIndex].Type, //0=theoretical, 1=code, 2=problem_resolution, + "topic": topicGen[topicIndex].Topic, + "temperature": 0.2, }); console.log(response.data); let dataGen; @@ -545,10 +545,10 @@ const AIToolModal = ({ setGeneratingLoading(true); if (!topicGen) throw ': no topic generated'; const response: AxiosResponse = await API.generateMaterial({ - numberOfWords: noW, - level: level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy - learningObjective: choices[choiceIndex], - topic: topicGen[topicIndex].Topic, + "numberOfWords": noW, + "level": level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy + "learningObjective": choices[choiceIndex], + "topic": topicGen[topicIndex].Topic, }); setScreen1(true); setScreen3(false); From 83fe99c5a9ac4f7007148cddf75330f15fe17594 Mon Sep 17 00:00:00 2001 From: tmaog Date: Sun, 17 Nov 2024 23:53:36 +0100 Subject: [PATCH 06/17] fix: typo --- src/components/Modals/AIToolModal.tsx | 44 +++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/components/Modals/AIToolModal.tsx b/src/components/Modals/AIToolModal.tsx index 8d29300..dbbfc7c 100644 --- a/src/components/Modals/AIToolModal.tsx +++ b/src/components/Modals/AIToolModal.tsx @@ -134,7 +134,7 @@ const AIToolModal = ({ throw ': no text given'; } const response: AxiosResponse = await API.analyseMaterial({ - "material": sourceMaterial, + material: sourceMaterial, }); console.log(response); setTitle(response.data.Title); @@ -265,9 +265,9 @@ const AIToolModal = ({ if (!topicGen) throw ': No topic generated'; setGeneratingLoading(true); const response: AxiosResponse = await API.generateLO({ - "Topic": topicGen[topicIndex].Topic, - "Level": level, - "Context": '', + Topic: topicGen[topicIndex].Topic, + Level: level, + Context: '', }); setChoices([ response.data.Remembering[0], @@ -396,20 +396,20 @@ const AIToolModal = ({ setGeneratingLoading(true); if (!topicGen) throw ': no topic generated'; const response: AxiosResponse = await API.generateNewExercise({ - "macroSubject": macroSubjectGen, - "title": titleGen, - "level": level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy - "typeOfActivity": exerciseType, //0=fill_the_gap, 1=question, 4=choice, - "learningObjective": choices[choiceIndex], - "bloomLevel": Math.round(choiceIndex / 2), //0=Remembering, 1=Understanding, 2=Applying, 3=Analyzing, 4=Evaluating, 5=Creating - "language": language, - "material": sourceMaterial, - "correctAnswersNumber": ca_n, - "distractorsNumber": da_n, - "easilyDiscardableDistractorsNumber": eda_n, - "assignmentType": topicGen[topicIndex].Type, //0=theoretical, 1=code, 2=problem_resolution, - "topic": topicGen[topicIndex].Topic, - "temperature": 0.2, + macroSubject: macroSubjectGen, + title: titleGen, + level: level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy + typeOfActivity: exerciseType, //0=fill_the_gap, 1=question, 4=choice, + learningObjective: choices[choiceIndex], + bloomLevel: Math.round(choiceIndex / 2), //0=Remembering, 1=Understanding, 2=Applying, 3=Analyzing, 4=Evaluating, 5=Creating + language: language, + material: sourceMaterial, + correctAnswersNumber: ca_n, + distractorsNumber: da_n, + easilyDiscardableDistractorsNumber: eda_n, + assignmentType: topicGen[topicIndex].Type, //0=theoretical, 1=code, 2=problem_resolution, + topic: topicGen[topicIndex].Topic, + temperature: 0.2, }); console.log(response.data); let dataGen; @@ -545,10 +545,10 @@ const AIToolModal = ({ setGeneratingLoading(true); if (!topicGen) throw ': no topic generated'; const response: AxiosResponse = await API.generateMaterial({ - "numberOfWords": noW, - "level": level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy - "learningObjective": choices[choiceIndex], - "topic": topicGen[topicIndex].Topic, + numberOfWords: noW, + level: level, //0=primary_school, 1=middle_school, 2=high_school, 3=college, 4=academy + learningObjective: choices[choiceIndex], + topic: topicGen[topicIndex].Topic, }); setScreen1(true); setScreen3(false); From f230f69db6fd74eb7bd0e8217daf7189e853b3c4 Mon Sep 17 00:00:00 2001 From: tmaog Date: Fri, 22 Nov 2024 11:29:40 +0100 Subject: [PATCH 07/17] fix: bug --- .../Forms/Fields/UploadDownloadField.tsx | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/components/Forms/Fields/UploadDownloadField.tsx b/src/components/Forms/Fields/UploadDownloadField.tsx index 4eb22e3..7b8ba17 100644 --- a/src/components/Forms/Fields/UploadDownloadField.tsx +++ b/src/components/Forms/Fields/UploadDownloadField.tsx @@ -12,6 +12,7 @@ import { AxiosResponse } from 'axios'; import { useEffect, useState } from 'react'; import { API } from '../../../data/api'; import useStore from '../../../store'; +import { PolyglotNode } from '../../../types/polyglotElements'; const FileUploadDownload = () => { const [file, setFile] = useState(); @@ -23,15 +24,15 @@ const FileUploadDownload = () => { setFile(event.target.files[0]); }; - const { getSelectedElement } = useStore((store) => ({ - getSelectedElement: store.getSelectedElement, + const { selectedElement } = useStore((store) => ({ + selectedElement: store.getSelectedElement, })); useEffect(() => { - const selectedElement = getSelectedElement(); if (!selectedElement) return; - setNodeId(selectedElement._id); - API.downloadFile({ nodeId: selectedElement._id }) + setNodeId((selectedElement as unknown as PolyglotNode)._id); + if (!nodeId) return; + API.downloadFile({ nodeId }) .then((response) => { if (response.data) { const contentDisposition = response.headers['content-disposition']; @@ -43,21 +44,22 @@ const FileUploadDownload = () => { }) .catch((error: AxiosResponse) => { console.log(error); + setFilename('Nessun file disponibile'); }); - }, []); - // Funzione per l'upload + }, [selectedElement]); + const handleUpload = async () => { if (!nodeId) return; if (!file) { toast({ - title: 'Seleziona un file e inserisci un ID nodo.', + title: 'Select a file.', status: 'warning', }); return; } if (file.type !== 'application/pdf') { toast({ - title: 'Il file selezionato non è un PDF.', + title: 'Selected file must be PDF.', status: 'warning', }); return; @@ -71,12 +73,20 @@ const FileUploadDownload = () => { API.uploadFile({ nodeId, file: formData, - }).then((resp) => - toast({ - title: 'File uploaded successfully.\n' + resp.data, - status: 'success', - }) - ); + }) + .then((resp) => + toast({ + title: 'File uploaded successfully.\n' + resp.data, + status: 'success', + }) + ) + .catch((error: AxiosResponse) => { + if (error.status == 413) + toast({ + title: 'Selected file is too Large.\n', + status: 'error', + }); + }); } catch (error) { toast({ title: "File's upload failed", From 8abfabf84cf5a3da5780a332ca7db1357cf99425 Mon Sep 17 00:00:00 2001 From: tmaog Date: Fri, 22 Nov 2024 11:32:03 +0100 Subject: [PATCH 08/17] fix: comment remove --- src/components/Forms/Fields/UploadDownloadField.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Forms/Fields/UploadDownloadField.tsx b/src/components/Forms/Fields/UploadDownloadField.tsx index 7b8ba17..8fdb942 100644 --- a/src/components/Forms/Fields/UploadDownloadField.tsx +++ b/src/components/Forms/Fields/UploadDownloadField.tsx @@ -95,7 +95,6 @@ const FileUploadDownload = () => { } }; - // Funzione per il download const handleDownload = async () => { if (!nodeId) return; try { From 4a7596c5a94f035129d70668620fa325f6d77a6b Mon Sep 17 00:00:00 2001 From: tmaog Date: Tue, 3 Dec 2024 10:52:50 +0100 Subject: [PATCH 09/17] fix: manuallyProgress selection bug --- src/components/Properties/Edges/EdgeProperties.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Properties/Edges/EdgeProperties.tsx b/src/components/Properties/Edges/EdgeProperties.tsx index feaa1e9..d26889a 100644 --- a/src/components/Properties/Edges/EdgeProperties.tsx +++ b/src/components/Properties/Edges/EdgeProperties.tsx @@ -22,7 +22,7 @@ const config = [ ], }, { - edgeTypes: ['manuallyProgressEdge'], + edgeTypes: ['manuallyProgressEdge','passFailEdge'], nodeTypes: ['CollaborativeModelingNode'], }, { From 49faa95e6883ccc059f08d3bbc59a6cfa835140b Mon Sep 17 00:00:00 2001 From: tmaog Date: Tue, 3 Dec 2024 10:53:25 +0100 Subject: [PATCH 10/17] fix: manuallyProgress selection bug --- src/components/Properties/Edges/EdgeProperties.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Properties/Edges/EdgeProperties.tsx b/src/components/Properties/Edges/EdgeProperties.tsx index d26889a..e0f0a1b 100644 --- a/src/components/Properties/Edges/EdgeProperties.tsx +++ b/src/components/Properties/Edges/EdgeProperties.tsx @@ -22,7 +22,7 @@ const config = [ ], }, { - edgeTypes: ['manuallyProgressEdge','passFailEdge'], + edgeTypes: ['manuallyProgressEdge', 'passFailEdge'], nodeTypes: ['CollaborativeModelingNode'], }, { From ae9c2ffc299ec05ab9f2d3b37ae7f43913356150 Mon Sep 17 00:00:00 2001 From: tmaog Date: Wed, 23 Apr 2025 14:31:56 +0200 Subject: [PATCH 11/17] fix: changes on AI api bodies --- src/components/Modals/AIToolModal.tsx | 54 ++++---- src/components/Modals/SummarizerModal.tsx | 9 +- .../Edges/failDebtEdgeProperties.tsx | 11 +- src/data/api.ts | 11 +- .../AIGenerativeTypes/AIGenerativeTypes.ts | 120 +++++++++++++----- .../AIGenerativeTypes/index.ts | 1 + src/types/polyglotElements/index.ts | 1 + 7 files changed, 125 insertions(+), 82 deletions(-) create mode 100644 src/types/polyglotElements/AIGenerativeTypes/index.ts diff --git a/src/components/Modals/AIToolModal.tsx b/src/components/Modals/AIToolModal.tsx index dbbfc7c..f4d451f 100644 --- a/src/components/Modals/AIToolModal.tsx +++ b/src/components/Modals/AIToolModal.tsx @@ -24,7 +24,7 @@ import { AxiosResponse } from 'axios'; import { useState } from 'react'; import { useFormContext } from 'react-hook-form'; import { API } from '../../data/api'; -import { TypeOfExercise } from '../../types/polyglotElements/AIGenerativeTypes/AIGenerativeTypes'; +import { EducationLevel, LearningOutcome, QuestionType, Topic } from '../../types/polyglotElements/AIGenerativeTypes/AIGenerativeTypes'; export type ModaTemplateProps = { isOpen: boolean; @@ -33,12 +33,6 @@ export type ModaTemplateProps = { action?: (i: boolean) => void; }; -export type Topic = { - Topic: string; - Type: TypeOfExercise; - Description: string; -}; - function delay(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } @@ -56,7 +50,7 @@ const AIToolModal = ({ const [language, setLanguage] = useState(''); const [level, setLevel] = useState(0); const [topicGen, setTopicGen] = useState([ - { Topic: 'prova', Type: 0, Description: '' }, + { topic: 'prova', explanation: '' }, ]); const [topicIndex, setTopicIndex] = useState(0); let exerciseType: number; @@ -134,7 +128,7 @@ const AIToolModal = ({ throw ': no text given'; } const response: AxiosResponse = await API.analyseMaterial({ - material: sourceMaterial, + text: sourceMaterial, }); console.log(response); setTitle(response.data.Title); @@ -241,7 +235,7 @@ const AIToolModal = ({ {topicGen.map((p, id) => { return ( ); })} @@ -257,14 +251,14 @@ const AIToolModal = ({ > Topic Description: - {topicGen[topicIndex].Description} + {topicGen[topicIndex].explanation}