/** * Evaluation Node - Version 4.8 * Runs an evaluation */ // Helper types for special n8n fields /** * Assignment type determines how the value is interpreted. * - string: Direct string value or expression evaluating to string * - number: Direct number value or expression evaluating to number * - boolean: Direct boolean value or expression evaluating to boolean * - array: Expression that evaluates to an array, e.g. ={{ [1, 2, 3] }} or ={{ $json.items }} * - object: Expression that evaluates to a plain object (not an array — use the array type for arrays), e.g. ={{ { key: 'value' } }} or ={{ $json.data }} * - binary: Property name of binary data in the input item, or expression to access binary data from previous nodes, e.g. ={{ $('Node').item.binary.data }} */ type AssignmentType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'binary'; type AssignmentCollectionValue = { assignments: Array<{ id: string; name: string; value: unknown; type: AssignmentType }> }; export interface EvaluationV48Params { operation?: 'setInputs' | 'setOutputs' | 'setMetrics' | 'checkIfEvaluating'; /** * Where to get the test dataset from * @displayOptions.show { operation: ["setOutputs"] } * @default dataTable */ source?: 'dataTable' | 'googleSheets' | Expression; /** * Authentication * @displayOptions.hide { source: ["dataTable"] } * @default oAuth2 */ authentication?: 'serviceAccount' | 'oAuth2' | Expression; /** * Inputs * @displayOptions.show { operation: ["setInputs"] } * @default {} */ inputs?: { /** Filter */ values?: Array<{ /** Name */ inputName?: string | Expression | PlaceholderValue; /** Value */ inputValue?: string | Expression | PlaceholderValue; }>; }; /** * Document Containing Dataset * @displayOptions.show { operation: ["setOutputs"] } * @displayOptions.hide { source: ["dataTable"] } * @default {"mode":"list","value":""} */ documentId?: { __rl: true; mode: 'list' | 'url' | 'id'; value: string; cachedResultName?: string }; /** * Sheet Containing Dataset * @displayOptions.show { operation: ["setOutputs"] } * @displayOptions.hide { source: ["dataTable"] } * @default {"mode":"list","value":""} */ sheetName?: { __rl: true; mode: 'list' | 'url' | 'id'; value: string; cachedResultName?: string }; /** * Data table * @displayOptions.show { source: ["dataTable"] } * @default {"mode":"list","value":""} */ dataTableId?: { __rl: true; mode: 'list' | 'id'; value: string; cachedResultName?: string }; /** * Outputs * @displayOptions.show { operation: ["setOutputs"] } * @default {} */ outputs?: { /** Filter */ values?: Array<{ /** Name */ outputName?: string | Expression | PlaceholderValue; /** Value */ outputValue?: string | Expression | PlaceholderValue; }>; }; /** * Metric * @displayOptions.show { operation: ["setMetrics"] } * @default correctness */ metric?: 'correctness' | 'helpfulness' | 'stringSimilarity' | 'categorization' | 'toolsUsed' | 'customMetrics'; /** * The expected output defined in your evaluation dataset, used as ground truth * @displayOptions.show { operation: ["setMetrics"], metric: ["correctness", "stringSimilarity", "categorization"] } */ expectedAnswer?: string | Expression | PlaceholderValue; /** * The real response generated by AI (e.g. an agent or LLM in the workflow) * @displayOptions.show { operation: ["setMetrics"], metric: ["correctness", "stringSimilarity", "categorization", "helpfulness"] } */ actualAnswer?: string | Expression | PlaceholderValue; /** * The original input or question submitted by the user * @displayOptions.show { operation: ["setMetrics"], metric: ["helpfulness"] } */ userQuery?: string | Expression | PlaceholderValue; /** * Enter the name(s) of the tool(s) you expect the AI to call (separated by commas) * @displayOptions.show { operation: ["setMetrics"], metric: ["toolsUsed"] } */ expectedTools?: string | Expression | PlaceholderValue; /** * Intermediate Steps (of Agent) * @hint Map the <code>intermediateSteps</code> field here. To see it, enable returning intermediate steps in the agent’s options * @displayOptions.show { operation: ["setMetrics"], metric: ["toolsUsed"] } */ intermediateSteps?: string | Expression | PlaceholderValue; /** * Instruction used to guide the model in scoring the actual answer’s correctness against the expected answer * @displayOptions.show { operation: ["setMetrics"], metric: ["correctness", "helpfulness"] } */ prompt?: string | Expression | PlaceholderValue; /** * Metrics to Return * @displayOptions.show { operation: ["setMetrics"], metric: ["customMetrics"] } * @default {"assignments":[{"name":"","value":"","type":"number"}]} */ metrics?: AssignmentCollectionValue; /** * Options * @displayOptions.show { operation: ["setMetrics"], metric: ["correctness", "helpfulness", "categorization", "stringSimilarity", "toolsUsed"] } * @default {} */ options?: { /** Set this parameter if you want to set a custom name to the metric * @default Correctness */ metricName?: string | Expression | PlaceholderValue; /** Input Prompt * @hint Requires the placeholders <code>{actual_answer}</code> and <code>{expected_answer}</code> */ inputPrompt?: string | Expression | PlaceholderValue; }; } export interface EvaluationV48SubnodeConfig { model?: LanguageModelInstance | LanguageModelInstance[]; } export interface EvaluationV48Credentials { googleApi: CredentialReference; googleSheetsOAuth2Api: CredentialReference; } interface EvaluationV48NodeBase { type: 'n8n-nodes-base.evaluation'; version: 4.8; credentials?: EvaluationV48Credentials; } export type EvaluationV48ParamsNode = EvaluationV48NodeBase & { config: NodeConfig & { subnodes?: EvaluationV48SubnodeConfig }; }; export type EvaluationV48Node = EvaluationV48ParamsNode;