From 6efaf4d2d3becf5daebf643462caeb4f93a13c77 Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Tue, 20 Feb 2024 14:31:59 +0100 Subject: [PATCH] fix: ai fill deep copy before slicing modules + minor improvements (#3255) * fix: AI fill deep copy before slicing modules * feat: green to accept + improve single input gen prompt * fix: prompt nit --- .../lib/components/copilot/IteratorGen.svelte | 17 +++++++++----- .../lib/components/copilot/MetadataGen.svelte | 7 +++++- .../components/copilot/PredicateGen.svelte | 8 +++---- .../components/copilot/StepInputGen.svelte | 22 ++++++++++++------- .../components/copilot/StepInputsGen.svelte | 20 +++++++++++------ 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/frontend/src/lib/components/copilot/IteratorGen.svelte b/frontend/src/lib/components/copilot/IteratorGen.svelte index 140672620e..1f2ed94a63 100644 --- a/frontend/src/lib/components/copilot/IteratorGen.svelte +++ b/frontend/src/lib/components/copilot/IteratorGen.svelte @@ -3,7 +3,7 @@ import Button from '../common/button/Button.svelte' import { getNonStreamingCompletion } from './lib' import { sendUserToast } from '$lib/toast' - import type { InputTransform } from '$lib/gen' + import type { Flow, InputTransform } from '$lib/gen' import ManualPopover from '../ManualPopover.svelte' import { createEventDispatcher, getContext } from 'svelte' import type { FlowEditorContext } from '../flows/types' @@ -13,6 +13,7 @@ import { dfs } from '../flows/dfs' import { yamlStringifyExceptKeys } from './utils' import { copilotInfo, stepInputCompletionEnabled } from '$lib/stores' + import { twMerge } from 'tailwind-merge' let generatedContent = '' let loading = false @@ -36,7 +37,8 @@ } abortController = new AbortController() loading = true - const idOrders = dfs($flowStore.value.modules, (x) => x.id) + const flow: Flow = JSON.parse(JSON.stringify($flowStore)) + const idOrders = dfs(flow.value.modules, (x) => x.id) const upToIndex = idOrders.indexOf($selectedId) if (upToIndex === -1) { throw new Error('Could not find the selected id in the flow') @@ -44,9 +46,7 @@ const flowDetails = 'Take into account the following information for never tested results:\n\n' + - yamlStringifyExceptKeys(sliceModules($flowStore.value.modules, upToIndex, idOrders), [ - 'lock' - ]) + + yamlStringifyExceptKeys(sliceModules(flow.value.modules, upToIndex, idOrders), ['lock']) + '' try { const availableData = { @@ -136,7 +136,12 @@ Only output the expression, do not explain or discuss.`