UNPKG

@n8n/n8n-nodes-langchain

Version:

![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)

164 lines (157 loc) 5.93 kB
/** * AI Agent Node - Version 1 * Generates an action plan and executes it. Can use external tools. */ export interface LcAgentV1Params { /** * Agent * @default conversationalAgent */ agent?: 'conversationalAgent' | 'openAiFunctionsAgent' | 'planAndExecuteAgent' | 'reActAgent' | 'sqlAgent'; /** * 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"] } * @displayOptions.hide { agent: ["sqlAgent"] } */ text: string | Expression<string>; /** * Options * @displayOptions.show { agent: ["toolsAgent"] } * @default {} */ 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>; }>; }; /** The message that will provide the agent with a list of tools to use */ humanMessage?: string | Expression<string> | PlaceholderValue; /** String to use directly as the human message template */ humanMessageTemplate?: string | Expression<string> | PlaceholderValue; /** String to put before the list of tools * @default Answer the following questions as best you can. You have access to the following tools: */ prefix?: string | Expression<string> | PlaceholderValue; /** String to put after the list of tools that will be used if chat model is used * @default Begin! Reminder to always use the exact characters `Final Answer` when responding. */ suffixChat?: string | Expression<string> | PlaceholderValue; /** String to put after the list of tools that will be used if regular model is used */ suffix?: string | Expression<string> | PlaceholderValue; /** Comma-separated list of tables to ignore from the database. If empty, no tables are ignored. */ ignoredTables?: string | Expression<string> | PlaceholderValue; /** Number of sample rows to include in the prompt to the agent. It helps the agent to understand the schema of the database but it also increases the amount of tokens used. * @default 3 */ includedSampleRows?: number | Expression<number>; /** Comma-separated list of tables to include in the database. If empty, all tables are included. */ includedTables?: string | Expression<string> | PlaceholderValue; /** Prefix prompt to use for the agent */ prefixPrompt?: string | Expression<string> | PlaceholderValue; /** Suffix prompt to use for the agent */ suffixPrompt?: string | Expression<string> | PlaceholderValue; /** The maximum number of results to return * @default 10 */ topK?: number | Expression<number>; }; /** * SQL database to connect to * @displayOptions.show { agent: ["sqlAgent"] } * @default sqlite */ dataSource?: 'mysql' | 'postgres' | 'sqlite' | Expression<string>; /** * Input Binary Field * @hint The name of the input binary field containing the file to be extracted * @displayOptions.show { agent: ["sqlAgent"], dataSource: ["sqlite"] } * @default data */ binaryPropertyName?: string | Expression<string> | PlaceholderValue; /** * Prompt * @displayOptions.show { agent: ["sqlAgent"] } */ input: string | Expression<string> | PlaceholderValue; } export interface LcAgentV1SubnodeConfig { model: LanguageModelInstance | LanguageModelInstance[]; memory?: MemoryInstance; tools?: ToolInstance[]; /** * @displayOptions.show { hasOutputParser: [true] } */ outputParser?: OutputParserInstance; } export interface LcAgentV1Credentials { mySql: CredentialReference; postgres: CredentialReference; } interface LcAgentV1NodeBase { type: '@n8n/n8n-nodes-langchain.agent'; version: 1; credentials?: LcAgentV1Credentials; } export type LcAgentV1ParamsNode = LcAgentV1NodeBase & { config: NodeConfig<LcAgentV1Params> & { subnodes: LcAgentV1SubnodeConfig }; }; export type LcAgentV1Node = LcAgentV1ParamsNode;