From ae9c2ffc299ec05ab9f2d3b37ae7f43913356150 Mon Sep 17 00:00:00 2001 From: tmaog Date: Wed, 23 Apr 2025 14:31:56 +0200 Subject: [PATCH 1/4] 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}