import type { OutputType, ScorerTypes } from './scorer.types'; import type { StepType } from './logging/step.types'; import type { components } from './api.types'; import type { ObjectToCamel } from 'ts-case-convert'; import type { Span } from './logging/span.types'; import type { Trace } from './logging/trace.types'; export type LogRecordsMetricsQueryRequestOpenAPI = components['schemas']['LogRecordsMetricsQueryRequest']; export type LogRecordsMetricsResponseOpenAPI = components['schemas']['LogRecordsMetricsResponse']; export type ScorerNameOpenAPI = components['schemas']['galileo_core__schemas__shared__scorers__scorer_name__ScorerName']; export type SingleMetricValue = number | string | boolean; export type MetricValueType = SingleMetricValue | SingleMetricValue[] | Record; /** * Built-in Galileo metric scorers. * * Values are human-readable UI labels used for scorer lookup via the API. * Naming convention: base name = LLM version, `Luna` suffix = SLM version. * * @example * ```typescript * import { GalileoMetrics } from 'galileo'; * * await enableMetrics({ * projectName: 'my-project', * logStreamName: 'default', * metrics: [GalileoMetrics.correctness, GalileoMetrics.completeness], * }); * ``` */ export declare const GalileoMetrics: { readonly actionAdvancement: "Action Advancement"; readonly actionAdvancementLuna: "Action Advancement (SLM)"; readonly actionCompletion: "Action Completion"; readonly actionCompletionLuna: "Action Completion (SLM)"; readonly agentEfficiency: "Agent Efficiency"; readonly agentFlow: "Agent Flow"; readonly chunkAttributionUtilization: "Chunk Attribution Utilization"; readonly chunkAttributionUtilizationLuna: "Chunk Attribution Utilization (SLM)"; readonly completeness: "Completeness"; readonly completenessLuna: "Completeness (SLM)"; readonly contextAdherence: "Context Adherence"; readonly contextAdherenceLuna: "Context Adherence (SLM)"; readonly contextPrecision: "Context Precision"; readonly contextRelevance: "Context Relevance"; readonly contextRelevanceLuna: "Context Relevance (SLM)"; readonly conversationQuality: "Conversation Quality"; readonly correctness: "Correctness"; readonly groundTruthAdherence: "Ground Truth Adherence"; readonly inputPii: "Input PII"; readonly inputPiiLuna: "Input PII (SLM)"; readonly inputSexism: "Input Sexism"; readonly inputSexismLuna: "Input Sexism (SLM)"; readonly inputTone: "Input Tone"; readonly inputToneLuna: "Input Tone (SLM)"; readonly inputToxicity: "Input Toxicity"; readonly inputToxicityLuna: "Input Toxicity (SLM)"; readonly instructionAdherence: "Instruction Adherence"; readonly outputPii: "Output PII"; readonly outputPiiLuna: "Output PII (SLM)"; readonly outputSexism: "Output Sexism"; readonly outputSexismLuna: "Output Sexism (SLM)"; readonly outputTone: "Output Tone"; readonly outputToneLuna: "Output Tone (SLM)"; readonly outputToxicity: "Output Toxicity"; readonly outputToxicityLuna: "Output Toxicity (SLM)"; readonly precisionAtK: "Precision@K"; readonly promptInjection: "Prompt Injection"; readonly promptInjectionLuna: "Prompt Injection (SLM)"; readonly reasoningCoherence: "Reasoning Coherence"; readonly sqlAdherence: "SQL Adherence"; readonly sqlCorrectness: "SQL Correctness"; readonly sqlEfficiency: "SQL Efficiency"; readonly sqlInjection: "SQL Injection"; readonly toolErrorRate: "Tool Error Rate"; readonly toolErrorRateLuna: "Tool Error Rate (SLM)"; readonly toolSelectionQuality: "Tool Selection Quality"; readonly toolSelectionQualityLuna: "Tool Selection Quality (SLM)"; readonly userIntentChange: "User Intent Change"; }; export interface Metric { name: string; version?: number; } export interface CreateCustomLlmMetricParams { name: string; userPrompt: string; nodeLevel?: StepType; cotEnabled?: boolean; modelName?: string; numJudges?: number; description?: string; tags?: string[]; outputType?: OutputType; groundTruth?: boolean; } export interface CreateCustomCodeMetricParams { name: string; codePath: string; nodeLevel: StepType; description?: string; tags?: string[]; outputType?: OutputType; /** Maximum time to wait for code validation in milliseconds (default: 60000ms / 1 minute) */ timeoutMs?: number; /** Interval between validation polling attempts in milliseconds (default: 1000ms) */ pollIntervalMs?: number; /** List of required metrics that this scorer depends on (can be GalileoMetrics values or metric name strings) */ requiredMetrics?: (GalileoMetrics | string)[]; } export interface DeleteMetricParams { scorerName: string; scorerType: ScorerTypes; } /** * Parameters for deleting a metric by name only. * This will delete all scorers with the given name, regardless of type. */ export interface DeleteMetricByNameParams { name: string; } /** * Configuration for a local metric that is computed client-side. * * This interface defines metrics that are evaluated on the client rather than server-side. * Local metrics are useful for custom scoring logic that needs to run in the client environment. */ export interface LocalMetricConfig { /** The name of the metric */ name: string; /** * The scoring function that computes the metric value. * Takes a trace or span and returns a metric value. */ scorerFn: (traceOrSpan: Trace | Span) => MetricValueType; /** * Optional aggregator function to combine scores from child spans. * Takes an array of metric values and returns an aggregated value. */ aggregatorFn?: (scores: MetricValueType[]) => MetricValueType; /** * The step types that can be scored by this metric. * @default ['llm'] */ scorableTypes?: string[]; /** * The step types that can have aggregated scores. * Must not contain any types in scorableTypes. * Can only contain 'trace' or 'workflow' step types. * @default ['trace'] */ aggregatableTypes?: string[]; } export type LogRecordsMetricsQueryRequest = ObjectToCamel; export type LogRecordsMetricsResponse = ObjectToCamel; /** * Type representing all valid Galileo metric labels. * This is a union of all human-readable label string literals from the GalileoMetrics const. * * Use the {@link GalileoMetrics} const object for runtime access to metric labels. */ export type GalileoMetrics = (typeof GalileoMetrics)[keyof typeof GalileoMetrics];