Skip to content

Commit 1fed4e3

Browse files
committed
fix: review changes
1 parent 580935d commit 1fed4e3

File tree

2 files changed

+3
-69
lines changed

2 files changed

+3
-69
lines changed

webserver/src/main/java/io/kestra/webserver/services/ai/FlowYamlBuilder.java

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public interface FlowYamlBuilder {
1212
{_{flowSchema}_}
1313
```
1414
15+
Before generating YAML, if {_{namespace}_} is provided, call the tool getPluginDefaults(tenantId, namespace) and use the returned plugin defaults to decide which task properties to omit. Respect `forced: true` defaults which override task values at runtime.
16+
1517
Additional runtime inputs available to you as variables (preferred over embedding data inside the schema):
1618
- {_{namespace}_}: An explicit namespace string provided separately. If present, prefer this over any namespace found in the YAML snippet.
1719
- {_{tenantId}_}: An explicit tenant identifier (may be null for single-tenant deployments). If present, prefer this over any tenantId found in the YAML snippet.
@@ -41,7 +43,7 @@ Avoid duplicating existing intent (e.g., if the Flow logs "hi" and the user want
4143
- Triggers expose some variables that can be accessed through `trigger.outputName` in expressions. The only variables available are those defined in the trigger's outputs.
4244
- Unless specified by the user, never assume a local port to serve any content, always use a remote URL (like a public HTTP server) to fetch content.
4345
- Unless specified by the user, do not use any authenticated API, always use public APIs or those that don't require authentication.
44-
- To avoid escaping quotes, use double quotes first and if you need quotes inside, use single ones. Only escape them if you have 3+ level quotes, for example: `message: "Hello {{inputs.userJson | jq('.name')}}"` is preferred but `message: "Hello \"Bob\""` may still be used.
46+
- To avoid escaping quotes, use double quotes first and if you need quotes inside, use single ones. For example: `message: "Hello {{inputs.userJson | jq('.name')}}"` is preferred.
4547
- A property key is unique within each type.
4648
- When fetching data from the JDBC plugin, always use fetchType: STORE.
4749
- Manipulating date in pebble expressions can be done through `dateAdd` (`{{now()|dateAdd(-1,'DAYS')}}`) and `date` filters (`{{"July 24, 2001"|date("yyyy-MM-dd",existingFormat="MMMM dd, yyyy")}}`). Any comparison from a number returned by `date` is a string so `| number` may be used before.
@@ -53,42 +55,6 @@ Avoid duplicating existing intent (e.g., if the Flow logs "hi" and the user want
5355
- If you have any other information to share to the user, add them as comments in the YAML using `#` at the beginning of the raw YAML.
5456
- Never add raw text in the response
5557
56-
Available Tools for Context Retrieval:
57-
58-
You have access to tools that retrieve namespace configuration on-demand. Prefer explicit variables `{_{namespace}_}` and `{_{tenantId}_}` when provided. Otherwise extract the namespace and tenantId from the "Current Flow YAML" section when calling these tools.
59-
60-
Namespace Context Tools :
61-
62-
1. KV Store Keys (getKvStoreKeys):
63-
- Call when user wants to interact with KV Store (read/write/list keys)
64-
- Returns: JSON with list of existing KV keys, descriptions, and update dates
65-
- Usage in flows: {{kv('keyName')}} to read, KV tasks (Get, Put, Delete) to manage
66-
67-
2. Plugin Defaults (getPluginDefaults) [EE Only]:
68-
- Call when user asks to integrate with specific technology (e.g., MongoDB, PostgreSQL)
69-
- Returns: JSON mapping plugin types to their default values
70-
- Apply defaults in generated tasks
71-
72-
3. Namespace Variables (getNamespaceVariables) [EE Only]:
73-
- Call when user references variables
74-
- Returns: JSON mapping variable names to values
75-
- Prefer namespace variables using {{vars.variableName}} over hardcoded values
76-
77-
4. Secret Names (getSecretNames) [EE Only]:
78-
- Call when user mentions secrets or credentials, or the technology being integrated typically requires credentials
79-
- Returns: JSON array of secret names (NOT values)
80-
- Reference using {{secret('secretName')}} for sensitive data
81-
82-
5. Complete Context (getAllNamespaceContext) [EE Only]:
83-
- Call for comprehensive namespace information
84-
- Returns: Combined context including KV keys, plugin defaults, variables, and secrets
85-
86-
Tool Calling Guidelines:
87-
- Use explicit `{_{namespace}_}` and `{_{tenantId}_}` placeholders, if not provided, do not call the tool.
88-
- Call tools BEFORE generating YAML to provide accurate suggestions
89-
- Only call tools relevant to the user's request
90-
- If namespace is not in YAML and flow is new, inform user namespace is required
91-
9258
IMPORTANT: If the user prompt cannot be fulfilled with the schema, instead of generating a Flow, reply: `{_{flowGenerationError}_}`.
9359
Do not invent properties or types. Strictly follow the provided schema.""")
9460
String buildFlow(

webserver/src/main/java/io/kestra/webserver/services/ai/NamespaceContextTool.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,4 @@ public String getKvStoreKeys(
4949
return "{}";
5050
}
5151
}
52-
53-
@Tool("Retrieves plugin defaults configured for the namespace")
54-
public String getPluginDefaults(
55-
@P("The namespace to query") String namespace,
56-
@P("The tenant ID (can be null for single-tenant)") String tenantId
57-
) {
58-
return "{}";
59-
}
60-
61-
@Tool("Retrieves namespace variables")
62-
public String getNamespaceVariables(
63-
@P("The namespace to query") String namespace,
64-
@P("The tenant ID (can be null for single-tenant)") String tenantId
65-
) {
66-
return "{}";
67-
}
68-
69-
@Tool("Retrieves secret names configured in the namespace")
70-
public String getSecretNames(
71-
@P("The namespace to query") String namespace,
72-
@P("The tenant ID (can be null for single-tenant)") String tenantId
73-
) {
74-
return "[]";
75-
}
76-
77-
@Tool("Retrieves complete namespace context")
78-
public String getAllNamespaceContext(
79-
@P("The namespace to query") String namespace,
80-
@P("The tenant ID (can be null for single-tenant)") String tenantId
81-
) {
82-
return "{}";
83-
}
8452
}

0 commit comments

Comments
 (0)