@n8n/n8n-nodes-langchain
Version:

124 lines (118 loc) • 4.48 kB
text/typescript
/**
* AI Agent Node - Version 3
* Generates an action plan and executes it. Can use external tools.
*/
export interface LcAgentV3Params {
/**
* Source for Prompt (User Message)
* @default auto
*/
promptType?: 'auto' | 'guardrails' | 'define' | Expression<string>;
/**
* Prompt (User Message)
* @builderHint Use expressions to include dynamic data from previous nodes (e.g., "={{ $json.input }}"). Static text prompts ignore incoming data.
* @displayOptions.show { promptType: ["define"] }
*/
text: string | Expression<string>;
hasOutputParser?: boolean;
needsFallback?: boolean;
options?: {
/** The message that will be sent to the agent before the conversation starts
* @builderHint Must include: agent's purpose, exact names of connected tools, and response instructions
* @default You are a helpful assistant
*/
systemMessage?: string | Expression<string> | PlaceholderValue;
/** The maximum number of iterations the agent will run before stopping
* @default 10
*/
maxIterations?: number | Expression<number>;
/** Whether or not the output should include intermediate steps the agent took
* @default false
*/
returnIntermediateSteps?: boolean | Expression<boolean>;
/** Whether or not binary images should be automatically passed through to the agent as image type messages
* @default true
*/
passthroughBinaryImages?: boolean | Expression<boolean>;
/** Custom metadata added to tracing events
* @default {}
*/
tracingMetadata?: {
/** Metadata
*/
values?: Array<{
/** Key
*/
key?: string | Expression<string> | PlaceholderValue;
/** The field value type
* @default stringValue
*/
type?: 'arrayValue' | 'booleanValue' | 'numberValue' | 'objectValue' | 'stringValue' | Expression<string>;
/** Value
* @displayOptions.show { type: ["stringValue"] }
*/
stringValue?: string | Expression<string> | PlaceholderValue;
/** Value
* @displayOptions.show { type: ["numberValue"] }
*/
numberValue?: string | Expression<string> | PlaceholderValue;
/** Value
* @displayOptions.show { type: ["booleanValue"] }
* @default true
*/
booleanValue?: 'true' | 'false' | Expression<string>;
/** Value
* @displayOptions.show { type: ["arrayValue"] }
*/
arrayValue?: string | Expression<string> | PlaceholderValue;
/** Value
* @displayOptions.show { type: ["objectValue"] }
* @default ={}
*/
objectValue?: IDataObject | string | Expression<string>;
}>;
};
/** Whether to automatically save <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executiondata/" target="_blank">highlighted data</a>. This data can then be used to filter executions in the Executions view. Available on Pro and Enterprise plans in n8n Cloud, and on Enterprise or registered Community Edition for self-hosted. Defaults to true.
* @default true
*/
autoSaveHighlightedData?: boolean | Expression<boolean>;
/** Whether this agent will stream the response in real-time as it generates text
* @default true
*/
enableStreaming?: boolean | Expression<boolean>;
/** Batch processing options for rate limiting
* @default {}
*/
batching?: {
/** How many items to process in parallel. This is useful for rate limiting, but might impact the log output ordering.
* @default 1
*/
batchSize?: number | Expression<number>;
/** Delay in milliseconds between batches. This is useful for rate limiting.
* @default 0
*/
delayBetweenBatches?: number | Expression<number>;
};
/** The maximum number of tokens to read from the chat memory history. Set to 0 to read all history.
* @default 0
*/
maxTokensFromMemory?: unknown;
};
}
export interface LcAgentV3SubnodeConfig {
model: LanguageModelInstance | LanguageModelInstance[];
memory?: MemoryInstance;
tools?: ToolInstance[];
/**
* @displayOptions.show { hasOutputParser: [true] }
*/
outputParser?: OutputParserInstance;
}
interface LcAgentV3NodeBase {
type: '@n8n/n8n-nodes-langchain.agent';
version: 3;
}
export type LcAgentV3ParamsNode = LcAgentV3NodeBase & {
config: NodeConfig<LcAgentV3Params> & { subnodes: LcAgentV3SubnodeConfig };
};
export type LcAgentV3Node = LcAgentV3ParamsNode;