feat: AI Workflow Builder backend (no-changelog) (#14837)

This commit is contained in:
oleg
2025-04-24 08:43:35 +02:00
committed by GitHub
parent 8c4b9f73f1
commit 1b1d6043d6
24 changed files with 1655 additions and 26 deletions

View File

@@ -0,0 +1,22 @@
import type { BaseMessage } from '@langchain/core/messages';
import { Annotation, END } from '@langchain/langgraph';
import type { SimpleWorkflow } from './types';
export const WorkflowState = Annotation.Root({
messages: Annotation<BaseMessage[]>({
reducer: (x, y) => x.concat(y),
}),
// The original prompt from the user.
prompt: Annotation<string>({ reducer: (x, y) => y ?? x ?? '' }),
// The list of logically derived workflow steps.
steps: Annotation<string[]>({ reducer: (x, y) => y ?? x ?? [] }),
// The list of candidate or selected n8n node names.
nodes: Annotation<string[]>({ reducer: (x, y) => y ?? x ?? [] }),
// The JSON representation of the workflow being built.
workflowJSON: Annotation<SimpleWorkflow>({
reducer: (x, y) => y ?? x ?? { nodes: [], connections: {} },
}),
// The next phase to be executed in the workflow graph.
next: Annotation<string>({ reducer: (x, y) => y ?? x ?? END, default: () => END }),
});