Skip to content

Commit 9b543e2

Browse files
committed
use openflow in system prompt
1 parent 1e19380 commit 9b543e2

File tree

1 file changed

+30
-0
lines changed
  • frontend/src/lib/components/copilot/chat/flow

1 file changed

+30
-0
lines changed

frontend/src/lib/components/copilot/chat/flow/core.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from '../shared'
2222
import type { ContextElement } from '../context'
2323
import type { ExtendedOpenFlow } from '$lib/components/flows/types'
24+
import openFlowSchema from './openFlow.json'
2425

2526
export type AIModuleAction = 'added' | 'modified' | 'removed' | 'shadowed' | undefined
2627

@@ -344,6 +345,20 @@ export const flowTools: Tool<FlowAIChatHelpers>[] = [
344345
}
345346
]
346347

348+
/**
349+
* Formats the OpenFlow schema for inclusion in the AI system prompt.
350+
* Extracts only the component schemas and formats them as JSON for the AI to reference.
351+
*/
352+
function formatOpenFlowSchemaForPrompt(): string {
353+
const schemas = openFlowSchema.components?.schemas
354+
if (!schemas) {
355+
return 'Schema not available'
356+
}
357+
358+
// Create a simplified schema reference that's easier for the AI to parse
359+
return JSON.stringify(schemas, null, 2)
360+
}
361+
347362
export function prepareFlowSystemMessage(customPrompt?: string): ChatCompletionSystemMessageParam {
348363
let content = `You are a helpful assistant that creates and edits workflows on the Windmill platform. You're provided with a bunch of tools to help you edit the flow.
349364
Follow the user instructions carefully.
@@ -473,6 +488,21 @@ To reference a specific resource in input_transforms, use: \`"$res:path/to/resou
473488
- Steps execute in the order they appear in the modules array
474489
- After applying, all modules are marked for review and displayed in a diff view
475490
491+
### OpenFlow Schema Reference
492+
Below is the complete OpenAPI schema for OpenFlow, which defines all available fields and their types. Use this as the authoritative reference when generating flow YAML:
493+
494+
\`\`\`json
495+
${formatOpenFlowSchemaForPrompt()}
496+
\`\`\`
497+
498+
When creating or modifying flows, ensure all fields match the types and structures defined in this schema. Key schemas to reference:
499+
- **OpenFlow**: The top-level flow structure
500+
- **FlowValue**: Contains modules array and optional preprocessor/failure modules
501+
- **FlowModule**: Individual flow steps with id, summary, and value
502+
- **FlowModuleValue**: Different module types (RawScript, PathScript, ForloopFlow, BranchOne, etc.)
503+
- **InputTransform**: Static values or JavaScript expressions for step inputs
504+
- **Retry, StopAfterIf, Suspend**: Configuration options for module behavior
505+
476506
### Contexts
477507
478508
You have access to the following contexts:

0 commit comments

Comments
 (0)