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 21d42043d4..f52421c463 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 @@ -11,6 +11,7 @@ export interface ModelComparisonOperationState extends BaseState { comparisonPairs: string[][]; goal: string; hasRun: boolean; + previousRunId?: string; } export const ModelComparisonOperation: Operation = { 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 2c2d3fef2c..060ea03c41 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 @@ -27,7 +27,7 @@ icon="pi pi-sparkles" size="small" :loading="isProcessingComparison" - @click.stop="processCompareModels" + @click.stop="onClickCompare" /> @@ -492,10 +492,32 @@ function generateOverview(output: string) { emit('update-status', OperatorStatus.DEFAULT); // This is a custom way of granting a default status to the operator, since it has no output } +function updatePreviousRunId() { + const state = cloneDeep(props.node.state); + state.previousRunId = uuidv4(); + emit('update-state', state); +} + +function onClickCompare() { + // If there is no previous run ID, or the node has already run, update the previousRunId + if (!props.node.state.previousRunId || props.node.state.hasRun) { + updatePreviousRunId(); + } + processCompareModels(); +} + // Create a task to compare the models const processCompareModels = async () => { isProcessingComparison.value = true; - const taskRes = await compareModels(modelIds.value, goalQuery.value, props.node.workflowId, props.node.id); + + // Add a unique ID to the request to avoid caching + if (!props.node.state.previousRunId) updatePreviousRunId(); + const request = ` + RequestID: ${props.node.state.previousRunId} + ${goalQuery.value} + `; + + const taskRes = await compareModels(modelIds.value, request, props.node.workflowId, props.node.id); compareModelsTaskId = taskRes.id; if (taskRes.status === TaskStatus.Success) { generateOverview(taskRes.output); @@ -521,6 +543,10 @@ useClientEvent(ClientEventType.TaskGollmCompareModel, (event: ClientEvent { + if (props.node.state.hasRun) { + processCompareModels(); + } + if (!isEmpty(props.node.state.comparisonImageIds)) { isLoadingStructuralComparisons.value = true; structuralComparisons.value = await getImages(props.node.state.comparisonImageIds); @@ -533,10 +559,7 @@ onMounted(async () => { modelCardsToCompare.value = modelsToCompare.value.map(({ metadata }) => metadata?.gollmCard); fields.value = [...new Set(modelCardsToCompare.value.flatMap((card) => (card ? Object.keys(card) : [])))]; - await buildJupyterContext(); - if (props.node.state.hasRun) { - processCompareModels(); - } + buildJupyterContext(); }); onUnmounted(() => {