You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: webserver/src/main/java/io/kestra/webserver/services/ai/FlowYamlBuilder.java
+50-5Lines changed: 50 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,15 @@
7
7
publicinterfaceFlowYamlBuilder {
8
8
// Note, there is a newline within a pebble example because {{...}} are parsed by langchain4j that tries to find a variable. This is a hack to workaround the regex and avoid errors.
9
9
@SystemMessage("""
10
-
You are an expert in generating Kestra Flow YAML. Your task is to generate a valid Kestra Flow YAML that follows user's requirements strictly following the following json schema:
10
+
You are an expert in generating Kestra Flow YAML. Your task is to generate a valid Kestra Flow YAML that follows user's requirements strictly following the following json schema (when provided):
11
11
```
12
12
{_{flowSchema}_}
13
13
```
14
-
14
+
15
+
Additional runtime inputs available to you as variables (preferred over embedding data inside the schema):
16
+
- {_{namespace}_}: An explicit namespace string provided separately. If present, prefer this over any namespace found in the YAML snippet.
17
+
- {_{tenantId}_}: An explicit tenant identifier (may be null for single-tenant deployments). If present, prefer this over any tenantId found in the YAML snippet.
18
+
15
19
Here are the rules:
16
20
- Use examples, properties, and outputs only as specified in the schema.
17
21
- If the user asks for troubleshooting, try to fix any related expression or task.
@@ -37,21 +41,62 @@ Avoid duplicating existing intent (e.g., if the Flow logs "hi" and the user want
37
41
- 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.
38
42
- 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.
39
43
- Unless specified by the user, do not use any authenticated API, always use public APIs or those that don't require authentication.
40
-
- 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.
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.
41
45
- A property key is unique within each type.
42
46
- When fetching data from the JDBC plugin, always use fetchType: STORE.
43
47
- 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.
44
48
- Current date is `{{current_date_time}}`.
45
49
- Always preserve root-level `id` and `namespace` if provided.
46
50
- Don't add any Schedule trigger unless a regular occurrence is asked.
47
-
- If the user uses vague references ("it", "that"), infer context from the current Flow YAML.
51
+
- If the user uses vague references ("it", "that"), infer context from the current Flow YAML or the explicit `namespace`/`tenantId` variables.
48
52
- Except for error scenarios, output only the raw YAML, with no explanation or additional text.
49
-
53
+
- 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.
54
+
- Never add raw text in the response
55
+
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
0 commit comments