From b82380904835f0bfe399188b8c698448054b41e3 Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 11:22:25 -0400 Subject: [PATCH 1/9] wip --- .../hmi-client/src/services/knowledge.ts | 8 +++++-- .../KnowledgeMiddlewareProxy.java | 18 ++++++++++++++++ .../KnowledgeResource.java | 21 +++++++++++++------ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/packages/client/hmi-client/src/services/knowledge.ts b/packages/client/hmi-client/src/services/knowledge.ts index cf4c1b8437..32fdba4b83 100644 --- a/packages/client/hmi-client/src/services/knowledge.ts +++ b/packages/client/hmi-client/src/services/knowledge.ts @@ -39,10 +39,14 @@ export async function fetchExtraction(id: string) { * @param framework [string] - the framework to use for the extraction, default to 'petrinet' * @return {Promise} */ -const latexToAMR = async (latex: string[], framework = 'petrinet'): Promise => { +const latexToAMR = async ( + latex: string[], + modelId: string, + framework = 'petrinet' +): Promise => { try { const response: AxiosResponse = await API.post( - `/knowledge/latex-to-amr/${framework}`, + `/knowledge/latex-to-amr/${framework}?modelId=${modelId}`, latex ); if (response && response?.status === 200 && response?.data) { diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java index a47f48b2d0..359e2bc957 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java @@ -115,4 +115,22 @@ ExtractionResponse postCodeToAMR( @QueryParam("name") String name, @QueryParam("description") String description ); + + /** + * Transform LaTeX equations to AMR + * @param equationType (String): the type of equation to transform + * @param model (String): the model to transform to + * @param modelId (String): the id of the model to transform to + * @param payload (List): the list of equations to transform + * @return (ExtractionResponse) + */ + @POST + @Path("/equations_to_amr") + @Consumes(MediaType.APPLICATION_JSON) + Response postLaTeXToAMR( + @QueryParam("equation_type") String equationType, + @QueryParam("model") String framework, + @QueryParam("model_id") String modelId, + List equations + ); } diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java index 8af9106792..3378d6be74 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java @@ -80,19 +80,28 @@ public Response postMathMLToAMR( @POST @Path("/latex-to-amr/{framework}") @Consumes(MediaType.APPLICATION_JSON) - public Model postLaTeXToAMR( + public Response postLaTeXToAMR( @DefaultValue("petrinet") @PathParam("framework") String framework, + @QueryParam("modelId") String modelId, List equations ) { /* Create the JSON request containing the LaTeX equations and model framework: * https://skema-unified.staging.terarium.ai/docs#/workflows/equations_to_amr_workflows_latex_equations_to_amr_post * ie: { "equations": [ "equation1", "equation2", ... ], "model": "petrinet" } */ - ObjectMapper mapper = new ObjectMapper(); - ObjectNode request = mapper.createObjectNode(); - request.put("model", framework); - request.set("equations", mapper.valueToTree(equations)); - return skemaUnifiedProxy.postLaTeXToAMR(request); + // ObjectMapper mapper = new ObjectMapper(); + // ObjectNode request = mapper.createObjectNode(); + // request.put("model", framework); + // request.set("equations", mapper.valueToTree(equations)); + // System.out.println(request.toString()); + // return skemaUnifiedProxy.postLaTeXToAMR(request); + // return knowledgeMiddlewareProxy.postLaTeXToAMR("latex", framework, modelId, equations); + + // take the response id from knowledgeMiddlewareProxy.postLaTeXToAMR and and fetch + // the model using the response id + Response res = knowledgeMiddlewareProxy.postLaTeXToAMR("latex", framework, modelId, equations); + System.out.println(res); + return res; }; /** From 76f8ec7edb7c8120d3da081afb902b81bb19af86 Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 15:37:02 -0400 Subject: [PATCH 2/9] feat: update equations to model endpoint --- .../model/petrinet/tera-model-equation.vue | 3 +- .../components/models/tera-model-diagram.vue | 3 +- .../hmi-client/src/services/knowledge.ts | 29 +++++++++++++------ packages/client/hmi-client/src/types/Types.ts | 10 +++++-- .../extractionservice/ExtractionResponse.java | 6 +--- .../ExtractionResponseResult.java | 18 ++++++++++++ .../KnowledgeMiddlewareProxy.java | 2 +- .../KnowledgeResource.java | 4 +-- 8 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java diff --git a/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue b/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue index 76c17ce427..e6c832cfb5 100644 --- a/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue +++ b/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue @@ -74,7 +74,8 @@ const updateLatexFormula = (equationsList: string[]) => { }; const updateModelFromEquations = async () => { - const updatedModel = await latexToAMR(equations.value); + console.log(props.model.id); + const updatedModel = await latexToAMR(equations.value, props.model.id); if (updatedModel) { emit('update-diagram', updateExistingModelContent(updatedModel, props.model)); } diff --git a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue index 06ab8cb8dd..c2b81c0ecb 100644 --- a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue +++ b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue @@ -549,7 +549,8 @@ const updatePetriNet = async (model: Model) => { // Update the model from the new mathml equations const onClickUpdateModel = async () => { - const model = (await latexToAMR(latexEquationList.value)) as Model; + console.log(props.model?.id); + const model = (await latexToAMR(latexEquationList.value, props.model?.id)) as Model; if (model) { if (props.model) { const newModel = updateExistingModelContent(model, props.model); diff --git a/packages/client/hmi-client/src/services/knowledge.ts b/packages/client/hmi-client/src/services/knowledge.ts index 32fdba4b83..2666796024 100644 --- a/packages/client/hmi-client/src/services/knowledge.ts +++ b/packages/client/hmi-client/src/services/knowledge.ts @@ -1,6 +1,6 @@ -import API, { Poller, PollerState, PollResponse } from '@/api/api'; +import API, { Poller, PollerState, PollResponse, PollerResult } from '@/api/api'; import { AxiosError, AxiosResponse } from 'axios'; -import { Artifact, Model } from '@/types/Types'; +import { Artifact, ExtractionResponse, Model } from '@/types/Types'; import { logger } from '@/utils/logger'; /** @@ -8,7 +8,7 @@ import { logger } from '@/utils/logger'; * @param id * @return {Promise} */ -export async function fetchExtraction(id: string) { +export async function fetchExtraction(id: string): Promise> { const pollerResult: PollResponse = { data: null, progress: null, error: null }; const poller = new Poller() .setPollAction(async () => { @@ -41,20 +41,31 @@ export async function fetchExtraction(id: string) { */ const latexToAMR = async ( latex: string[], - modelId: string, + modelId?: string, framework = 'petrinet' ): Promise => { try { - const response: AxiosResponse = await API.post( + const response: AxiosResponse = await API.post( `/knowledge/latex-to-amr/${framework}?modelId=${modelId}`, latex ); - if (response && response?.status === 200 && response?.data) { - return response.data; + if (response && response?.status === 200) { + const { id, status } = response.data; + if (status === 'queued') { + const result = await fetchExtraction(id); + if (result?.state === PollerState.Done) { + if (result?.data?.job_result?.status_code === 200) { + return result.data.job_result.amr as Model; + } + } + } + if (status === 'finished' && response.data.result.job_result.status_code === 200) { + return response.data.result.job_result.amr as Model; + } } - logger.error(`LaTeX to AMR request failed`, { toastTitle: 'Error - SKEMA Unified' }); + logger.error(`LaTeX to AMR request failed`, { toastTitle: 'Error - Knowledge Middleware' }); } catch (error: unknown) { - logger.error(error, { showToast: false, toastTitle: 'Error - SKEMA Unified' }); + logger.error(error, { showToast: false, toastTitle: 'Error - Knowledge Middleware' }); } return null; }; diff --git a/packages/client/hmi-client/src/types/Types.ts b/packages/client/hmi-client/src/types/Types.ts index 9f3888b365..08f88d6d71 100644 --- a/packages/client/hmi-client/src/types/Types.ts +++ b/packages/client/hmi-client/src/types/Types.ts @@ -238,12 +238,16 @@ export interface PetriNetModel { export interface ExtractionResponse { id: string; + status: string; + result: ExtractionResponseResult; +} + +export interface ExtractionResponseResult { created_at: Date; enqueued_at: Date; started_at: Date; - status: string; - extraction_error: string; - result: any; + job_error: string; + job_result: any; } export interface DKG { diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java index 725f188c0d..97fd21c53e 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java @@ -11,10 +11,6 @@ @TSModel public class ExtractionResponse { private String id; - private Date created_at; - private Date enqueued_at; - private Date started_at; private String status; - private String extraction_error; - private Object result; + private ExtractionResponseResult result; } diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java new file mode 100644 index 0000000000..d82a79463f --- /dev/null +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java @@ -0,0 +1,18 @@ +package software.uncharted.terarium.hmiserver.models.extractionservice; + +import lombok.Data; +import lombok.experimental.Accessors; +import software.uncharted.terarium.hmiserver.annotations.TSModel; + +import java.util.Date; + +@Data +@Accessors(chain = true) +@TSModel +public class ExtractionResponseResult { + private Date created_at; + private Date enqueued_at; + private Date started_at; + private String job_error; + private Object job_result; +} diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java index 359e2bc957..b10f26e79a 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java @@ -127,7 +127,7 @@ ExtractionResponse postCodeToAMR( @POST @Path("/equations_to_amr") @Consumes(MediaType.APPLICATION_JSON) - Response postLaTeXToAMR( + ExtractionResponse postLaTeXToAMR( @QueryParam("equation_type") String equationType, @QueryParam("model") String framework, @QueryParam("model_id") String modelId, diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java index 3378d6be74..b08927f2ed 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java @@ -80,7 +80,7 @@ public Response postMathMLToAMR( @POST @Path("/latex-to-amr/{framework}") @Consumes(MediaType.APPLICATION_JSON) - public Response postLaTeXToAMR( + public ExtractionResponse postLaTeXToAMR( @DefaultValue("petrinet") @PathParam("framework") String framework, @QueryParam("modelId") String modelId, List equations @@ -99,7 +99,7 @@ public Response postLaTeXToAMR( // take the response id from knowledgeMiddlewareProxy.postLaTeXToAMR and and fetch // the model using the response id - Response res = knowledgeMiddlewareProxy.postLaTeXToAMR("latex", framework, modelId, equations); + ExtractionResponse res = knowledgeMiddlewareProxy.postLaTeXToAMR("latex", framework, modelId, equations); System.out.println(res); return res; }; From b8ce6137ccbb4acb825370e33264e79a2040338a Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 15:51:16 -0400 Subject: [PATCH 3/9] cleanup --- .../model/petrinet/tera-model-equation.vue | 1 - .../components/models/tera-model-diagram.vue | 1 - .../hmi-client/src/services/knowledge.ts | 1 + .../KnowledgeMiddlewareProxy.java | 8 +++--- .../KnowledgeResource.java | 26 +++++-------------- 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue b/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue index e6c832cfb5..9e695d2537 100644 --- a/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue +++ b/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue @@ -74,7 +74,6 @@ const updateLatexFormula = (equationsList: string[]) => { }; const updateModelFromEquations = async () => { - console.log(props.model.id); const updatedModel = await latexToAMR(equations.value, props.model.id); if (updatedModel) { emit('update-diagram', updateExistingModelContent(updatedModel, props.model)); diff --git a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue index c2b81c0ecb..75650279e7 100644 --- a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue +++ b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue @@ -549,7 +549,6 @@ const updatePetriNet = async (model: Model) => { // Update the model from the new mathml equations const onClickUpdateModel = async () => { - console.log(props.model?.id); const model = (await latexToAMR(latexEquationList.value, props.model?.id)) as Model; if (model) { if (props.model) { diff --git a/packages/client/hmi-client/src/services/knowledge.ts b/packages/client/hmi-client/src/services/knowledge.ts index 2666796024..9855691a38 100644 --- a/packages/client/hmi-client/src/services/knowledge.ts +++ b/packages/client/hmi-client/src/services/knowledge.ts @@ -36,6 +36,7 @@ export async function fetchExtraction(id: string): Promise> { /** * Transform a list of LaTeX strings to an AMR * @param latex string[] - list of LaTeX strings representing a model + * @param modelId string - the model id to use for the extraction * @param framework [string] - the framework to use for the extraction, default to 'petrinet' * @return {Promise} */ diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java index b10f26e79a..5ab89b6e33 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/proxies/knowledgemiddleware/KnowledgeMiddlewareProxy.java @@ -118,10 +118,10 @@ ExtractionResponse postCodeToAMR( /** * Transform LaTeX equations to AMR - * @param equationType (String): the type of equation to transform - * @param model (String): the model to transform to - * @param modelId (String): the id of the model to transform to - * @param payload (List): the list of equations to transform + * @param equationType (String): [latex, mathml] + * @param model (String): AMR model return type. Defaults to "petrinet". Options: "regnet", "petrinet". + * @param modelId (String): the id of the model (to update) based on the set of equations + * @param payload (List): the list of LaTeX strings representing the functions that are used to convert to AMR * @return (ExtractionResponse) */ @POST diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java index b08927f2ed..7f573dd718 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/resources/knowledgemiddleware/KnowledgeResource.java @@ -73,9 +73,10 @@ public Response postMathMLToAMR( /** * Post LaTeX to SKEMA Unified service to get an AMR - * @param framework (String) the type of AMR to return. Defaults to "petrinet". Options: "regnet", "petrinet". - * @param equations (List): A list of LaTeX strings representing the functions that are used to convert to AMR mode. - * @return (Model): The AMR model + * @param framework (String) the type of AMR to return. Defaults to "petrinet". Options: "regnet", "petrinet". + * @param modelId (String): the id of the model (to update) based on the set of equations + * @param equations (List): A list of LaTeX strings representing the functions that are used to convert to AMR model + * @return (ExtractionResponse): The response from the extraction service */ @POST @Path("/latex-to-amr/{framework}") @@ -85,23 +86,8 @@ public ExtractionResponse postLaTeXToAMR( @QueryParam("modelId") String modelId, List equations ) { - /* Create the JSON request containing the LaTeX equations and model framework: - * https://skema-unified.staging.terarium.ai/docs#/workflows/equations_to_amr_workflows_latex_equations_to_amr_post - * ie: { "equations": [ "equation1", "equation2", ... ], "model": "petrinet" } - */ - // ObjectMapper mapper = new ObjectMapper(); - // ObjectNode request = mapper.createObjectNode(); - // request.put("model", framework); - // request.set("equations", mapper.valueToTree(equations)); - // System.out.println(request.toString()); - // return skemaUnifiedProxy.postLaTeXToAMR(request); - // return knowledgeMiddlewareProxy.postLaTeXToAMR("latex", framework, modelId, equations); - - // take the response id from knowledgeMiddlewareProxy.postLaTeXToAMR and and fetch - // the model using the response id - ExtractionResponse res = knowledgeMiddlewareProxy.postLaTeXToAMR("latex", framework, modelId, equations); - System.out.println(res); - return res; + // http://knowledge-middleware.staging.terarium.ai/#/default/equations_to_amr_equations_to_amr_post + return knowledgeMiddlewareProxy.postLaTeXToAMR("latex", framework, modelId, equations); }; /** From 2193e7c2402a4249f295df32f4b29891b2c0b243 Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 15:54:31 -0400 Subject: [PATCH 4/9] minor refactor --- packages/client/hmi-client/src/services/knowledge.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/client/hmi-client/src/services/knowledge.ts b/packages/client/hmi-client/src/services/knowledge.ts index 9855691a38..6d1e266685 100644 --- a/packages/client/hmi-client/src/services/knowledge.ts +++ b/packages/client/hmi-client/src/services/knowledge.ts @@ -54,10 +54,8 @@ const latexToAMR = async ( const { id, status } = response.data; if (status === 'queued') { const result = await fetchExtraction(id); - if (result?.state === PollerState.Done) { - if (result?.data?.job_result?.status_code === 200) { - return result.data.job_result.amr as Model; - } + if (result?.state === PollerState.Done && result?.data?.job_result?.status_code === 200) { + return result.data.job_result.amr as Model; } } if (status === 'finished' && response.data.result.job_result.status_code === 200) { From 74c3897d380accbd592449c8cd772e5f53094fa1 Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 15:56:36 -0400 Subject: [PATCH 5/9] fix spacing --- .../models/extractionservice/ExtractionResponse.java | 6 +++--- .../models/extractionservice/ExtractionResponseResult.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java index 97fd21c53e..19721f09dc 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponse.java @@ -10,7 +10,7 @@ @Accessors(chain = true) @TSModel public class ExtractionResponse { - private String id; - private String status; - private ExtractionResponseResult result; + private String id; + private String status; + private ExtractionResponseResult result; } diff --git a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java index d82a79463f..ed537ed936 100644 --- a/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java +++ b/packages/services/hmi-server/src/main/java/software/uncharted/terarium/hmiserver/models/extractionservice/ExtractionResponseResult.java @@ -11,8 +11,8 @@ @TSModel public class ExtractionResponseResult { private Date created_at; - private Date enqueued_at; - private Date started_at; + private Date enqueued_at; + private Date started_at; private String job_error; private Object job_result; } From 85699855d5ada2d9d8167ef30ce19f97819ee5f9 Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 16:01:02 -0400 Subject: [PATCH 6/9] remove unnecessary type casting --- .../hmi-client/src/components/models/tera-model-diagram.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue index 75650279e7..2ea9cf5466 100644 --- a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue +++ b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue @@ -549,7 +549,7 @@ const updatePetriNet = async (model: Model) => { // Update the model from the new mathml equations const onClickUpdateModel = async () => { - const model = (await latexToAMR(latexEquationList.value, props.model?.id)) as Model; + const model = await latexToAMR(latexEquationList.value, props.model?.id); if (model) { if (props.model) { const newModel = updateExistingModelContent(model, props.model); From 7e80f634e77ac1d436731a909e08edceff0ab1f3 Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 17:06:32 -0400 Subject: [PATCH 7/9] change order of latexToAMR params --- .../src/components/model/petrinet/tera-model-equation.vue | 2 +- .../hmi-client/src/components/models/tera-model-diagram.vue | 2 +- packages/client/hmi-client/src/services/knowledge.ts | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue b/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue index 9e695d2537..fc2a1d3655 100644 --- a/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue +++ b/packages/client/hmi-client/src/components/model/petrinet/tera-model-equation.vue @@ -74,7 +74,7 @@ const updateLatexFormula = (equationsList: string[]) => { }; const updateModelFromEquations = async () => { - const updatedModel = await latexToAMR(equations.value, props.model.id); + const updatedModel = await latexToAMR(equations.value, 'petrinet', props.model.id); if (updatedModel) { emit('update-diagram', updateExistingModelContent(updatedModel, props.model)); } diff --git a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue index 2ea9cf5466..89764bebf7 100644 --- a/packages/client/hmi-client/src/components/models/tera-model-diagram.vue +++ b/packages/client/hmi-client/src/components/models/tera-model-diagram.vue @@ -549,7 +549,7 @@ const updatePetriNet = async (model: Model) => { // Update the model from the new mathml equations const onClickUpdateModel = async () => { - const model = await latexToAMR(latexEquationList.value, props.model?.id); + const model = await latexToAMR(latexEquationList.value, 'petrinet', props.model?.id); if (model) { if (props.model) { const newModel = updateExistingModelContent(model, props.model); diff --git a/packages/client/hmi-client/src/services/knowledge.ts b/packages/client/hmi-client/src/services/knowledge.ts index b4c4928cd6..65270c6390 100644 --- a/packages/client/hmi-client/src/services/knowledge.ts +++ b/packages/client/hmi-client/src/services/knowledge.ts @@ -36,14 +36,14 @@ export async function fetchExtraction(id: string): Promise> { /** * Transform a list of LaTeX strings to an AMR * @param latex string[] - list of LaTeX strings representing a model - * @param modelId string - the model id to use for the extraction * @param framework [string] - the framework to use for the extraction, default to 'petrinet' + * @param modelId string - the model id to use for the extraction * @return {Promise} */ const latexToAMR = async ( latex: string[], - modelId?: string, - framework = 'petrinet' + framework = 'petrinet', + modelId?: string ): Promise => { try { const response: AxiosResponse = await API.post( From 3742c7349c9febb4b4451fced853a8ae83d097ab Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 17:07:03 -0400 Subject: [PATCH 8/9] typing --- packages/client/hmi-client/src/services/knowledge.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/services/knowledge.ts b/packages/client/hmi-client/src/services/knowledge.ts index 65270c6390..b7f630d70c 100644 --- a/packages/client/hmi-client/src/services/knowledge.ts +++ b/packages/client/hmi-client/src/services/knowledge.ts @@ -42,7 +42,7 @@ export async function fetchExtraction(id: string): Promise> { */ const latexToAMR = async ( latex: string[], - framework = 'petrinet', + framework: string = 'petrinet', modelId?: string ): Promise => { try { From a4a47355a5a3a64d884863d2c1c1ff043d27baaa Mon Sep 17 00:00:00 2001 From: Al-Jami Ismail Date: Fri, 1 Sep 2023 17:17:45 -0400 Subject: [PATCH 9/9] tiny fix --- packages/client/hmi-client/src/services/knowledge.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/services/knowledge.ts b/packages/client/hmi-client/src/services/knowledge.ts index cc18224b77..3b5559f4ce 100644 --- a/packages/client/hmi-client/src/services/knowledge.ts +++ b/packages/client/hmi-client/src/services/knowledge.ts @@ -61,7 +61,7 @@ const latexToAMR = async ( return result.data.job_result.amr as Model; } } - if (status === 'finished' && response.data.result.job_result.status_code === 200) { + if (status === 'finished' && response.data.result.job_result?.status_code === 200) { return response.data.result.job_result.amr as Model; } }