import { type CreateCustomLlmMetricParams, type CreateCustomCodeMetricParams, type DeleteMetricParams, type DeleteMetricByNameParams } from '../types'; import { GalileoMetrics, type LocalMetricConfig, type Metric } from '../types/metrics.types'; import type { BaseScorerVersionResponse, ScorerConfig } from '../types/scorer.types'; import type { Trace } from '../types/logging/trace.types'; import { type Span } from '../types/logging/span.types'; import type { LogRecordsMetricsQueryRequest, LogRecordsMetricsResponse } from '../types/metrics.types'; /** * Metrics class for managing metrics in the Galileo platform. * Public-facing API that delegates to internal utilities and GalileoApiClient. */ export declare class Metrics { /** * Creates a custom LLM metric. * * @param params - The parameters for creating the custom LLM metric. * @returns A promise that resolves when the metric is created. */ createCustomLlmMetric({ name, userPrompt, nodeLevel, cotEnabled, modelName, numJudges, description, tags, outputType, groundTruth }: CreateCustomLlmMetricParams): Promise; /** * Creates a custom code-based metric. * * @param params - The parameters for creating the custom code metric. * @returns A promise that resolves with the created scorer version. */ createCustomCodeMetric({ name, codePath, nodeLevel, description, tags, outputType, timeoutMs, pollIntervalMs, requiredMetrics }: CreateCustomCodeMetricParams): Promise; /** * Deletes a metric by its name and type. * * @param params - The parameters for deleting the metric. * @returns A promise that resolves when the scorer is successfully deleted. * @throws Error if the scorer with the given name is not found. */ deleteMetric(params: DeleteMetricParams): Promise; /** * Deletes a metric by its name only. Deletes all scorers with the given name. * * @param params - The parameters for deleting the metric by name. * @returns A promise that resolves when all matching scorers are successfully deleted. * @throws Error if no scorer with the given name is found. */ deleteMetric(params: DeleteMetricByNameParams): Promise; /** * Queries for metrics in a project. * * @param projectId - The ID of the project to search in. * @param options - The query options. * @param options.startTime - The start time for the metrics query (ISO date-time string). * @param options.endTime - The end time for the metrics query (ISO date-time string). * @param options.logStreamId - (Optional) The log stream ID to filter by. * @param options.experimentId - (Optional) The experiment ID to filter by. * @param options.metricsTestingId - (Optional) The metrics testing ID to filter by. * @param options.interval - (Optional) The time interval for aggregating metrics. * @param options.groupBy - (Optional) The field to group metrics by. * @param options.filters - (Optional) Filters to apply to the query. * @returns A promise that resolves to the metrics search results. */ query(projectId: string, options: LogRecordsMetricsQueryRequest): Promise; /** * Process metrics and create scorer configurations for log streams or experiments. * * This function categorizes metrics into server-side and client-side types, * validates they exist, and registers server-side metrics with Galileo. * * @param projectId - The ID of the project * @param runId - The ID of the run (can be experiment ID or log stream ID) * @param metrics - List of metrics to configure. Can include: * - GalileoMetrics const object values (e.g., GalileoMetrics.correctness) * - Metric objects with name and optional version * - LocalMetricConfig objects for client-side scoring * - String names of metrics * @returns A promise that resolves to a tuple containing: * - Array of ScorerConfig objects for server-side metrics * - Array of LocalMetricConfig objects for client-side metrics * @throws Error if any specified metrics are unknown or don't exist in Galileo * * @example * ```typescript * const [scorerConfigs, localMetrics] = await metrics.createMetricConfigs( * 'project-123', * 'log-stream-456', * [ * GalileoMetrics.correctness, * GalileoMetrics.completeness, * 'toxicity', * { name: 'custom_metric', version: 2 } * ] * ); * ``` */ createMetricConfigs(projectId: string, runId: string, metrics: (GalileoMetrics | Metric | LocalMetricConfig | string)[]): Promise<[ScorerConfig[], LocalMetricConfig[]]>; /** * Populates local metrics on a trace or span by computing scores client-side. * * This function recursively processes child spans and applies aggregator functions * when applicable. * * @param step - The trace or span to populate metrics on * @param localMetrics - List of local metric configurations to apply */ populateLocalMetrics(step: Trace | Span, localMetrics: LocalMetricConfig[]): void; /** * Internal helper method to recursively populate a single local metric. * * @param step - The trace or span to process * @param localMetric - The local metric configuration * @param scores - Accumulated scores from child spans (for aggregation) */ private _populateLocalMetric; /** * Validates a LocalMetricConfig to ensure it meets requirements. * * @param localMetric - The local metric configuration to validate * @throws Error if validation fails */ private validateLocalMetricConfig; } /** * Creates a custom LLM metric. * * @param params - The parameters for creating the custom LLM metric. * @returns A promise that resolves when the metric is created. */ export declare const createCustomLlmMetric: (params: CreateCustomLlmMetricParams) => Promise; /** * Creates a custom code-based metric. * * @param params - The parameters for creating the custom code metric. * @returns A promise that resolves with the created scorer version. */ export declare const createCustomCodeMetric: (params: CreateCustomCodeMetricParams) => Promise; /** * Deletes a metric by its name and type, or by name only. * * @param params - The parameters for deleting the metric. * @returns A promise that resolves when the scorer(s) are successfully deleted. * @throws Error if the scorer with the given name is not found. */ export declare const deleteMetric: (params: DeleteMetricParams | DeleteMetricByNameParams) => Promise; /** * Searches for metrics in a project. * @param options - The search query parameters. * @param options.projectId - The ID of the project to search in. * @param options.startTime - The start time for the metrics query (ISO date-time string). * @param options.endTime - The end time for the metrics query (ISO date-time string). * @param options.logStreamId - (Optional) The log stream ID to filter by. * @param options.experimentId - (Optional) The experiment ID to filter by. * @param options.metricsTestingId - (Optional) The metrics testing ID to filter by. * @param options.filters - (Optional) Filters to apply to the query. * @param options.interval - (Optional) The time interval for aggregating metrics. * @param options.groupBy - (Optional) The field to group metrics by. * @returns A promise that resolves to the search results. */ export declare const getMetrics: (options: LogRecordsMetricsQueryRequest & { projectId: string; }) => Promise; /** * Process metrics and create scorer configurations for log streams or experiments. * * This function categorizes metrics into server-side and client-side types, * validates they exist, and registers server-side metrics with Galileo. * * @param projectId - The ID of the project * @param runId - The ID of the run (can be experiment ID or log stream ID) * @param metrics - List of metrics to configure. Can include: * - GalileoMetrics const object values (e.g., GalileoMetrics.correctness) * - GalileoMetrics const object values (e.g., GalileoMetrics.correctness) * - Metric objects with name and optional version * - LocalMetricConfig objects for client-side scoring * - String names of metrics * @returns A promise that resolves to a tuple containing: * - Array of ScorerConfig objects for server-side metrics * - Array of LocalMetricConfig objects for client-side metrics * @throws Error if any specified metrics are unknown or don't exist in Galileo * * @example * ```typescript * const [scorerConfigs, localMetrics] = await createMetricConfigs( * 'project-123', * 'log-stream-456', * [ * GalileoMetrics.correctness, * GalileoMetrics.completeness, * GalileoMetrics.correctness, * GalileoMetrics.completeness, * 'toxicity', * { name: 'custom_metric', version: 2 } * ] * ); * ``` */ export declare const createMetricConfigs: (projectId: string, runId: string, metrics: (GalileoMetrics | Metric | LocalMetricConfig | string)[]) => Promise<[ScorerConfig[], LocalMetricConfig[]]>; /** * Populates local metrics on a trace or span by computing scores client-side. * * This function recursively processes child spans and applies aggregator functions * when applicable. * * @param step - The trace or span to populate metrics on * @param localMetrics - List of local metric configurations to apply * @internal Used by GalileoLogger.flush; not part of the public API. */ export declare const populateLocalMetrics: (step: Trace | Span, localMetrics: LocalMetricConfig[]) => void;