Skip to content

Commit

Permalink
clean up workflow typing, localstorage transform, remove unused noteb… (
Browse files Browse the repository at this point in the history
  • Loading branch information
mwdchang authored Aug 15, 2024
1 parent 744978c commit 5e12fe0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ const optionsMenuItems = ref([
}
]);
const toggleOptionsMenu = (event) => {
const toggleOptionsMenu = (event: MouseEvent) => {
optionsMenu.value.toggle(event);
};
const teraOperatorRefs = ref();
Expand Down Expand Up @@ -567,7 +567,7 @@ const showAddComponentMenu = () => {
const { getDragData } = useDragEvent();
function onDrop(event) {
function onDrop(event: DragEvent) {
const { assetId, assetType } = getDragData('initAssetNode') as {
assetId: string;
assetType: AssetType;
Expand Down Expand Up @@ -603,12 +603,12 @@ function onDrop(event) {
}
}
function toggleContextMenu(event) {
function toggleContextMenu(event: MouseEvent) {
contextMenu.value.show(event);
updateNewNodePosition(event);
}
function updateNewNodePosition(event) {
function updateNewNodePosition(event: MouseEvent) {
newNodePosition.x = (event.offsetX - canvasTransform.x) / canvasTransform.k;
newNodePosition.y = (event.offsetY - canvasTransform.y) / canvasTransform.k;
}
Expand Down Expand Up @@ -880,6 +880,9 @@ const handleDrilldown = () => {
watch(
() => [props.assetId],
async () => {
// Save previous location
setLocalStorageTransform(wf.value.getId(), canvasTransform);
isRenamingWorkflow.value = false; // Closes rename input if opened in previous workflow
if (wf.value && workflowDirty) {
workflowService.updateWorkflow(wf.value.dump());
Expand Down Expand Up @@ -917,6 +920,7 @@ onMounted(() => {
workflowService.updateWorkflow(wf.value.dump());
workflowDirty = false;
}
setLocalStorageTransform(wf.value.getId(), canvasTransform);
}, WORKFLOW_SAVE_INTERVAL);
});
Expand Down
11 changes: 0 additions & 11 deletions packages/client/hmi-client/src/services/beaker.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/client/hmi-client/src/services/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type {
WorkflowOutput
} from '@/types/workflow';
import { WorkflowPortStatus, OperatorStatus, WorkflowOperationTypes } from '@/types/workflow';
import { summarizeNotebook } from './beaker';

/**
* A wrapper class around the workflow data struture to make it easier
Expand Down Expand Up @@ -675,29 +674,6 @@ export function updateOutputPort(node: WorkflowNode<any>, updatedOutputPort: Wor
outputPort = Object.assign(outputPort, updatedOutputPort);
}

// Keep track of the summary generation requests to prevent multiple requests for the same workflow output
// TODO: Instead of relying on the Ids stored in memory, consider creating a table in the backend to store the summaries to keep track of their status and results.
const summaryGenerationRequestIds = new Set<string>();

export async function generateSummary(
node: WorkflowNode<any>,
outputPort: WorkflowOutput<any>,
createNotebookFn: ((state: any, value: WorkflowPort['value']) => Promise<any>) | null
) {
if (!node || !createNotebookFn || summaryGenerationRequestIds.has(outputPort.id)) return null;
try {
summaryGenerationRequestIds.add(outputPort.id);
const notebook = await createNotebookFn(outputPort.state, outputPort.value);
const result = await summarizeNotebook(notebook);
if (!result.summary) throw new Error('AI Generated summary is empty.');
return result;
} catch {
return { title: outputPort.label, summary: 'Generating AI summary has failed.' };
} finally {
summaryGenerationRequestIds.delete(outputPort.id);
}
}

// Check if the current-state matches that of the output-state.
//
// Note operatorState subsumes the keys of the outputState, thus if
Expand Down

0 comments on commit 5e12fe0

Please sign in to comment.