/**
 * Evaluation Node - Version 4.6
 * 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 EvaluationV46Params {
  operation?: 'setInputs' | 'setOutputs' | 'setMetrics' | 'checkIfEvaluating';
/**
 * Where to get the test dataset from
 * @displayOptions.show { operation: ["setOutputs"] }
 * @default googleSheets
 */
    source?: 'dataTable' | 'googleSheets' | Expression<string>;
/**
 * Authentication
 * @displayOptions.hide { source: ["dataTable"] }
 * @default oAuth2
 */
    authentication?: 'serviceAccount' | 'oAuth2' | Expression<string>;
/**
 * Inputs
 * @displayOptions.show { operation: ["setInputs"] }
 * @default {}
 */
    inputs?: {
        /** Filter
     */
    values?: Array<{
      /** Name
       */
      inputName?: string | Expression<string> | PlaceholderValue;
      /** Value
       */
      inputValue?: string | Expression<string> | 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<string> | PlaceholderValue;
      /** Value
       */
      outputValue?: string | Expression<string> | PlaceholderValue;
    }>;
  };
/**
 * Metric
 * @displayOptions.show { operation: ["setMetrics"] }
 * @default customMetrics
 */
    metric?: unknown;
/**
 * The expected output defined in your evaluation dataset, used as ground truth
 * @displayOptions.show { operation: ["setMetrics"], metric: ["correctness", "stringSimilarity", "categorization"] }
 */
    expectedAnswer?: string | Expression<string> | PlaceholderValue;
/**
 * The real response generated by AI (e.g. an agent or LLM in the workflow)
 * @displayOptions.show { operation: ["setMetrics"], metric: ["correctness", "stringSimilarity", "categorization"] }
 */
    actualAnswer?: string | Expression<string> | PlaceholderValue;
/**
 * The original input or question submitted by the user
 * @displayOptions.show { operation: ["setMetrics"], metric: ["helpfulness"] }
 */
    userQuery?: string | Expression<string> | 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<string> | PlaceholderValue;
/**
 * Intermediate Steps (of Agent)
 * @hint Map the &lt;code&gt;intermediateSteps&lt;/code&gt; field here. To see it, enable returning intermediate steps in the agent’s options
 * @displayOptions.show { operation: ["setMetrics"], metric: ["toolsUsed"] }
 */
    intermediateSteps?: string | Expression<string> | PlaceholderValue;
/**
 * Instruction used to guide the model in scoring the actual answer’s correctness against the expected answer
 * @displayOptions.show { operation: ["setMetrics"], metric: ["correctness"] }
 */
    prompt?: string | Expression<string> | 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"] }
 * @default {}
 */
    options?: {
    /** Set this parameter if you want to set a custom name to the metric
     * @default Correctness
     */
    metricName?: string | Expression<string> | PlaceholderValue;
    /** Input Prompt
     * @hint Requires the placeholders &lt;code&gt;{actual_answer}&lt;/code&gt; and &lt;code&gt;{expected_answer}&lt;/code&gt;
     */
    inputPrompt?: string | Expression<string> | PlaceholderValue;
  };
}

export interface EvaluationV46SubnodeConfig {
  model?: LanguageModelInstance | LanguageModelInstance[];
}

export interface EvaluationV46Credentials {
  googleApi: CredentialReference;
  googleSheetsOAuth2Api: CredentialReference;
}

interface EvaluationV46NodeBase {
  type: 'n8n-nodes-base.evaluation';
  version: 4.6;
  credentials?: EvaluationV46Credentials;
}

export type EvaluationV46ParamsNode = EvaluationV46NodeBase & {
  config: NodeConfig<EvaluationV46Params> & { subnodes?: EvaluationV46SubnodeConfig };
};

export type EvaluationV46Node = EvaluationV46ParamsNode;