From a58da796bf0f200e67599563a56c1718003ff997 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Tue, 26 Aug 2025 15:25:17 +0200 Subject: [PATCH] fix(frontend): ai agent step nits (#6469) * fix(frontend): ai agent step nits * fix provider select * nits * nit --- frontend/src/lib/components/ArgInput.svelte | 16 +++++++++++++--- .../lib/components/copilot/MetadataGen.svelte | 17 ++++++++++++++--- .../flows/common/FlowCardHeader.svelte | 2 +- frontend/src/lib/components/flows/flowInfers.ts | 4 +++- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index a15c461c12..5e8b189a09 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -937,11 +937,21 @@ selected={oneOfSelected} on:selected={({ detail }) => { oneOfSelected = detail - const prevValueKeys = Object.keys( + const selectedObjProperties = oneOf?.find((o) => o.title == detail)?.properties ?? {} - ) + const newValueKeys = Object.keys(selectedObjProperties) const toKeep = {} - for (const key of prevValueKeys) { + for (const key of newValueKeys) { + // Check if there is a select (enum) in the newly selected oneOf and if the current value is not in the enum, skip it + if ( + !['kind', 'label'].includes(key) && + selectedObjProperties[key]?.enum && + value && + value[key] !== undefined && + !selectedObjProperties[key].enum.includes(value[key]) + ) { + continue + } toKeep[key] = value[key] } const tagKey = oneOf.find((o) => Object.keys(o.properties ?? {}).includes('kind')) diff --git a/frontend/src/lib/components/copilot/MetadataGen.svelte b/frontend/src/lib/components/copilot/MetadataGen.svelte index f9e5b0c9a6..91b6c43cbf 100644 --- a/frontend/src/lib/components/copilot/MetadataGen.svelte +++ b/frontend/src/lib/components/copilot/MetadataGen.svelte @@ -32,6 +32,7 @@ You are a helpful AI assistant. You generate very brief summaries from scripts. The summaries need to be as short as possible (maximum 8 words) and only give a global idea. Do not specify the programming language. Do not use any punctation. Avoid using prepositions and articles. Examples: List the commits of a GitHub repository, Divide a number by 16, etc.. +**Return only the summary, no other text.** `, user: ` Generate a very short summary for the script below: @@ -48,6 +49,7 @@ These descriptions are used to explain to other users what the script does and h Be as short as possible to give a global idea, maximum 3-4 sentences. All scripts export an asynchronous function called main, do not include it in the description. Do not describe how to call it either. +**Return only the description, no other text.** `, user: ` Generate a description for the script below: @@ -61,6 +63,7 @@ Generate a description for the script below: system: ` You are a helpful AI assistant. You generate very brief summaries from scripts. The summaries need to be as short as possible (maximum 8 words) and only give a global idea. Do not use any punctation. Avoid using prepositions and articles. +**Return only the summary, no other text.** `, user: ` Summarize the flow below in one very short sentence without punctation: @@ -73,6 +76,7 @@ You are a helpful AI assistant. You generate descriptions from flow. These descriptions are used to explain to other users what the flow does and how to use it. Be as short as possible to give a global idea, maximum 3-4 sentences. Do not include line breaks. +**Return only the description, no other text.** `, user: ` Generate a description for the flow below: @@ -81,13 +85,15 @@ Generate a description for the flow below: }, agentToolFunctionName: { system: ` -You are a helpful AI assistant. You generate function names from scripts. -These function names will be used by an AI agent to call this tool. +You are a helpful AI assistant. You generate tool names from scripts. +These tool names will be used by an AI agent to call this tool. +It has to be based on the script code content not on the main function name. It has to respect the following regex: /[a-zA-Z0-9_]+/ Examples: generate_image, classify_image, summarize_text, etc. +**Return only the tool name, no other text.** `, user: ` -Generate a function name for the script below: +Generate a tool name for the script below: {code}`, placeholderName: 'code' } @@ -317,6 +323,11 @@ Generate a function name for the script below: on:focus={() => (focused = true)} on:blur={() => (focused = false)} /> + {#if promptConfigName === 'agentToolFunctionName' && !validateToolName(content ?? '')} +
+ Invalid tool name, should only contain letters, numbers and underscores +
+ {/if} {/if} diff --git a/frontend/src/lib/components/flows/common/FlowCardHeader.svelte b/frontend/src/lib/components/flows/common/FlowCardHeader.svelte index 39e3f615fd..780be61a18 100644 --- a/frontend/src/lib/components/flows/common/FlowCardHeader.svelte +++ b/frontend/src/lib/components/flows/common/FlowCardHeader.svelte @@ -72,7 +72,7 @@
{#if flowModuleValue} diff --git a/frontend/src/lib/components/flows/flowInfers.ts b/frontend/src/lib/components/flows/flowInfers.ts index 887fe6e418..9bf57a06ee 100644 --- a/frontend/src/lib/components/flows/flowInfers.ts +++ b/frontend/src/lib/components/flows/flowInfers.ts @@ -106,7 +106,9 @@ export async function loadSchemaFromModule(module: FlowModule): Promise<{ type: 'number' }, temperature: { - type: 'number' + type: 'number', + description: + 'Controls randomness in text generation. Range: 0.0 (deterministic) to 2.0 (random).' } }, required: ['provider', 'model', 'user_message'],