Function: createCustomLlmMetric()

function createCustomLlmMetric(
  name: string,
  userPrompt: string,
  nodeLevel: StepType,
  cotEnabled: boolean,
  modelName: string,
  numJudges: number,
  description: string,
  tags: string[],
  outputType: OutputType,
): Promise<{
  cot_enabled?: null | boolean;
  generated_scorer?: null | {
    chain_poll_template: {
      explanation_field_name?: string;
      metric_description?: null | string;
      metric_few_shot_examples?: object[];
      metric_system_prompt?: null | string;
      template: string;
      value_field_name?: string;
    };
    id: string;
    instructions?: null | string;
    name: string;
    user_prompt?: null | string;
  };
  id: string;
  input_type?:
    | null
    | "basic"
    | "llm_spans"
    | "retriever_spans"
    | "sessions_normalized"
    | "sessions_trace_io_only"
    | "tool_spans"
    | "trace_input_only"
    | "trace_io_only"
    | "trace_normalized"
    | "trace_output_only";
  model_name?: null | string;
  num_judges?: null | number;
  output_type?:
    | null
    | "boolean"
    | "categorical"
    | "count"
    | "discrete"
    | "freeform"
    | "percentage";
  registered_scorer?: null | {
    id: string;
    name: string;
  };
  scoreable_node_types?: null | string[];
  version: number;
}>;
Defined in: src/utils/metrics.ts:23 Creates a custom LLM metric.

Parameters

name

string The name of the custom metric.

userPrompt

string The user prompt for the metric.

nodeLevel

StepType = StepType.llm (Optional) The node level for the metric, i.e. StepType.llm, StepType.trace. Defaults to StepType.llm.

cotEnabled

boolean = true (Optional) Whether chain of thought is enabled. Defaults to true.

modelName

string = 'gpt-4.1-mini' (Optional) The model name to use. Defaults to ‘gpt-4.1-mini’.

numJudges

number = 3 (Optional) The number of judges to use. Defaults to 3.

description

string = '' (Optional) A description for the metric.

tags

string[] = [] (Optional) Tags to associate with the metric.

outputType

OutputType = OutputType.BOOLEAN (Optional) The output type for the metric. Defaults to OutputType.BOOLEAN.

Returns

Promise<{ cot_enabled?: null | boolean; generated_scorer?: | null | { chain_poll_template: { explanation_field_name?: string; metric_description?: null | string; metric_few_shot_examples?: object[]; metric_system_prompt?: null | string; template: string; value_field_name?: string; }; id: string; instructions?: null | string; name: string; user_prompt?: null | string; }; id: string; input_type?: | null | "basic" | "llm_spans" | "retriever_spans" | "sessions_normalized" | "sessions_trace_io_only" | "tool_spans" | "trace_input_only" | "trace_io_only" | "trace_normalized" | "trace_output_only"; model_name?: null | string; num_judges?: null | number; output_type?: | null | "boolean" | "categorical" | "count" | "discrete" | "freeform" | "percentage"; registered_scorer?: | null | { id: string; name: string; }; scoreable_node_types?: null | string[]; version: number; }> A promise that resolves when the metric is created.