From 8982e3ded58adc48dbaa86e57c190de643f36533 Mon Sep 17 00:00:00 2001 From: Shawn Yama Date: Tue, 20 Aug 2024 12:33:52 -0400 Subject: [PATCH 1/8] save overview in state --- .../model-comparison-operation.ts | 2 + .../tera-model-comparison.vue | 37 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/model-comparison-operation.ts b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/model-comparison-operation.ts index 4f6f99d61d..f3825975d7 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/model-comparison-operation.ts +++ b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/model-comparison-operation.ts @@ -5,6 +5,7 @@ const DOCUMENTATION_URL = 'https://githubicom/gyorilab/mira/blob/7314765ab409ddc9647269ad2381055f1cd67706/notebooks/hackathon_2023.10/dkg_grounding_model_comparison.ipynb#L307'; export interface ModelComparisonOperationState extends BaseState { + overview: string; notebookHistory: NotebookHistory[]; hasCodeRun: boolean; comparisonImageIds: string[]; @@ -24,6 +25,7 @@ export const ModelComparisonOperation: Operation = { action: () => {}, initState: () => { const init: ModelComparisonOperationState = { + overview: '', notebookHistory: [], hasCodeRun: false, comparisonImageIds: [] diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue index e6f8dda506..de1c71335a 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue @@ -10,8 +10,10 @@
-

{{ llmAnswer }}

-

Analyzing models metadata to generate a detailed comparison analysis...

+

+ Analyzing models metadata to generate a detailed comparison analysis... +

+

{{ node.state.overview }}

@@ -137,7 +139,7 @@ import { ClientEvent, ClientEventType, TaskResponse, TaskStatus, type Model } fr import { WorkflowNode, WorkflowPortStatus } from '@/types/workflow'; import { logger } from '@/utils/logger'; import Button from 'primevue/button'; -import { computed, onMounted, onUnmounted, ref } from 'vue'; +import { onMounted, onUnmounted, ref } from 'vue'; import { VAceEditor } from 'vue3-ace-editor'; import { VAceEditorInstance } from 'vue3-ace-editor/types'; @@ -179,20 +181,13 @@ const fields = ref([]); const isLoadingStructuralComparisons = ref(false); const structuralComparisons = ref([]); -const compareModelsTaskId = ref(''); -const compareModelsTaskOutput = ref(''); +let compareModelsTaskId = ''; +let compareModelsTaskOutput = ''; const code = ref(props.node.state.notebookHistory?.[0]?.code ?? ''); const llmThoughts = ref([]); const isKernelReady = ref(false); const contextLanguage = ref('python3'); -const llmAnswer = computed(() => { - if (!compareModelsTaskOutput.value) return ''; - const str = b64DecodeUnicode(compareModelsTaskOutput.value); - const parsedValue = JSON.parse(str) as CompareModelsResponseType; - return parsedValue.response; -}); - const initializeAceEditor = (editorInstance: any) => { editor = editorInstance; }; @@ -294,16 +289,26 @@ async function buildJupyterContext() { async function processCompareModels(modelIds, workflowId?: string, nodeId?: string) { const taskRes = await compareModels(modelIds, workflowId, nodeId); - compareModelsTaskId.value = taskRes.id; + compareModelsTaskId = taskRes.id; if (taskRes.status === TaskStatus.Success) { - compareModelsTaskOutput.value = taskRes.output; + compareModelsTaskOutput = taskRes.output; } } +function generateOverview() { + if (!compareModelsTaskOutput || !isEmpty(props.node.state.overview)) return; + const str = b64DecodeUnicode(compareModelsTaskOutput); + const parsedValue = JSON.parse(str) as CompareModelsResponseType; + const state = cloneDeep(props.node.state); + state.overview = parsedValue.response; + emit('update-state', state); +} + useClientEvent(ClientEventType.TaskGollmCompareModel, (event: ClientEvent) => { - if (!event.data || event.data.id !== compareModelsTaskId.value) return; + if (!event.data || event.data.id !== compareModelsTaskId) return; if (event.data.status !== TaskStatus.Success) return; - compareModelsTaskOutput.value = event.data.output; + compareModelsTaskOutput = event.data.output; + generateOverview(); }); onMounted(async () => { From ac8b64ba8e5247882f64ac146f70ce9931c445d2 Mon Sep 17 00:00:00 2001 From: Shawn Yama Date: Tue, 20 Aug 2024 13:04:11 -0400 Subject: [PATCH 2/8] custom status update since this has no output --- .../model-comparison/tera-model-comparison-node.vue | 12 +++++++++--- .../ops/model-comparison/tera-model-comparison.vue | 1 + .../src/components/workflow/tera-workflow.vue | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue index 292a2ca4da..0753db89d3 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue @@ -9,16 +9,22 @@ import { watch, computed } from 'vue'; import Button from 'primevue/button'; import TeraOperatorPlaceholder from '@/components/operator/tera-operator-placeholder.vue'; -import { WorkflowNode, WorkflowPortStatus } from '@/types/workflow'; +import { WorkflowNode, WorkflowPortStatus, OperatorStatus } from '@/types/workflow'; import { ModelComparisonOperationState } from './model-comparison-operation'; -const emit = defineEmits(['append-input-port', 'open-drilldown']); +const emit = defineEmits(['append-input-port', 'open-drilldown', 'update-status']); const props = defineProps<{ node: WorkflowNode; }>(); -const hasAtLeastTwoValues = computed(() => props.node.inputs.filter((input) => input.value).length >= 2); +const hasAtLeastTwoValues = computed(() => { + const flag = props.node.inputs.filter((input) => input.value).length >= 2; + // This is a custom way of granting a success status to the operator, since it has no output + if (flag) emit('update-status', OperatorStatus.SUCCESS); + else emit('update-status', OperatorStatus.INVALID); + return flag; +}); watch( () => props.node.inputs, diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue index de1c71335a..7f14cb08e5 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue @@ -296,6 +296,7 @@ async function processCompareModels(modelIds, workflowId?: string, nodeId?: stri } function generateOverview() { + // Generate if there is no overview and the comparison task has been completed if (!compareModelsTaskOutput || !isEmpty(props.node.state.overview)) return; const str = b64DecodeUnicode(compareModelsTaskOutput); const parsedValue = JSON.parse(str) as CompareModelsResponseType; diff --git a/packages/client/hmi-client/src/components/workflow/tera-workflow.vue b/packages/client/hmi-client/src/components/workflow/tera-workflow.vue index 51cddf09a9..33e7d71bbb 100644 --- a/packages/client/hmi-client/src/components/workflow/tera-workflow.vue +++ b/packages/client/hmi-client/src/components/workflow/tera-workflow.vue @@ -88,6 +88,7 @@ @append-output="(event: any) => appendOutput(node, event)" @append-input-port="(event: any) => appendInputPort(node, event)" @update-state="(event: any) => updateWorkflowNodeState(node, event)" + @update-status="(status: OperatorStatus) => updateWorkflowNodeStatus(currentActiveNode, status)" @open-drilldown="addOperatorToRoute(node.id)" /> @@ -158,7 +159,7 @@ :spawn-animation="drilldownSpawnAnimation" @append-output="(event: any) => appendOutput(currentActiveNode, event)" @update-state="(event: any) => updateWorkflowNodeState(currentActiveNode, event)" - @update-status="(event: any) => updateWorkflowNodeStatus(currentActiveNode, event)" + @update-status="(status: OperatorStatus) => updateWorkflowNodeStatus(currentActiveNode, status)" @select-output="(event: any) => selectOutput(currentActiveNode, event)" @close="addOperatorToRoute(null)" @update-output-port="(event: any) => updateOutputPort(currentActiveNode, event)" From 22dc52ea282a1ed7e88add75d27216d666191a53 Mon Sep 17 00:00:00 2001 From: Shawn Yama Date: Tue, 20 Aug 2024 13:14:18 -0400 Subject: [PATCH 3/8] fix emit --- .../ops/model-comparison/tera-model-comparison-node.vue | 4 ++-- .../hmi-client/src/components/workflow/tera-workflow.vue | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue index 0753db89d3..8b1c286151 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison-node.vue @@ -20,8 +20,8 @@ const props = defineProps<{ const hasAtLeastTwoValues = computed(() => { const flag = props.node.inputs.filter((input) => input.value).length >= 2; - // This is a custom way of granting a success status to the operator, since it has no output - if (flag) emit('update-status', OperatorStatus.SUCCESS); + // This is a custom way of granting a default status to the operator, since it has no output + if (flag) emit('update-status', OperatorStatus.DEFAULT); else emit('update-status', OperatorStatus.INVALID); return flag; }); diff --git a/packages/client/hmi-client/src/components/workflow/tera-workflow.vue b/packages/client/hmi-client/src/components/workflow/tera-workflow.vue index 33e7d71bbb..25d4110f87 100644 --- a/packages/client/hmi-client/src/components/workflow/tera-workflow.vue +++ b/packages/client/hmi-client/src/components/workflow/tera-workflow.vue @@ -88,7 +88,7 @@ @append-output="(event: any) => appendOutput(node, event)" @append-input-port="(event: any) => appendInputPort(node, event)" @update-state="(event: any) => updateWorkflowNodeState(node, event)" - @update-status="(status: OperatorStatus) => updateWorkflowNodeStatus(currentActiveNode, status)" + @update-status="(status: OperatorStatus) => updateWorkflowNodeStatus(node, status)" @open-drilldown="addOperatorToRoute(node.id)" /> From f91e51f14a69b38ee2eceaef118b902786342045 Mon Sep 17 00:00:00 2001 From: Shawn Yama Date: Tue, 20 Aug 2024 13:45:01 -0400 Subject: [PATCH 4/8] markdown render compoennt --- packages/client/hmi-client/package.json | 2 + .../tera-model-comparison.vue | 7 +- yarn.lock | 82 +++++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/packages/client/hmi-client/package.json b/packages/client/hmi-client/package.json index 875f8de3e6..a59176780d 100644 --- a/packages/client/hmi-client/package.json +++ b/packages/client/hmi-client/package.json @@ -73,6 +73,7 @@ "vue": "3.3.13", "vue-feather": "2.0.0", "vue-gtag": "2.0.1", + "vue-markdown-render": "^2.2.1", "vue-router": "4.2.5", "vue3-ace-editor": "2.2.4", "vue3-draggable-resizable": "1.6.5", @@ -84,6 +85,7 @@ "@rushstack/eslint-patch": "1.10.4", "@types/d3": "7.4.3", "@types/lodash": "4.17.7", + "@types/markdown-it": "^14.1.2", "@types/node": "18.19.3", "@vitejs/plugin-vue": "4.6.2", "@vitest/coverage-c8": "0.24.5", diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue index 7f14cb08e5..625c50a3d7 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-comparison/tera-model-comparison.vue @@ -13,7 +13,7 @@

Analyzing models metadata to generate a detailed comparison analysis...

-

{{ node.state.overview }}

+ @@ -126,6 +126,7 @@