import { type ExperimentResponseType, type ExperimentUpdateRequest, type ExperimentDatasetRequest, type ExperimentsAvailableColumnsResponse, type RunExperimentWithFunctionOutput, type RunExperimentParams, type RunExperimentOutput } from '../types/experiment.types'; import type { GalileoMetrics, LocalMetricConfig, Metric } from '../types/metrics.types'; import type { DatasetRecord } from '../types/dataset.types'; /** * Entity class for managing experiments. * Provides high-level methods for creating, getting, updating, deleting, and querying experiments. */ export declare class Experiments { private client; private ensureClient; /** * Enriches an experiment response with `metricAggregates` (alias for * `structuredAggregateMetrics`) and a runtime deprecation warning on `aggregateMetrics`. */ private _enrichExperimentResponse; /** * Returns all available columns for the experiment comparison table. * * Scorer-backed metric columns have IDs of the form `"metrics/{scorer-uuid}"`, which maps * directly to the keys in `experiment.metricAggregates`. Use `column.metricKeyAlias` for * the legacy snake_case metric name and `column.label` for the display label. * * @example * const cols = await experiments.getExperimentColumns({ projectName: 'My Project' }); * const colMap = Object.fromEntries((cols.columns ?? []).map(c => [c.id, c])); * for (const [metricId, agg] of Object.entries(experiment.metricAggregates ?? {})) { * const col = colMap[`metrics/${metricId}`]; // null metricKeyAlias for system metrics * const label = col?.label ?? metricId; * console.log(`${label}: avg=${agg.avg}`); * } */ getExperimentColumns(options: { projectId?: string; projectName?: string; }): Promise; /** * Gets an experiment by ID or name. * @param options - The options for getting an experiment. * @param options.projectId - (Optional) The unique identifier of the project. * @param options.projectName - (Optional) The name of the project. * @param options.id - (Optional) The unique identifier of the experiment. * @param options.name - (Optional) The name of the experiment. * @returns A promise that resolves to the experiment, or undefined if not found. */ getExperiment(options: { projectId?: string; projectName?: string; id?: string; name?: string; }): Promise; /** * Creates a new experiment. * @param options - The options for creating an experiment. * @param options.name - The name of the experiment. * @param options.projectId - (Optional) The unique identifier of the project. * @param options.projectName - (Optional) The name of the project. * @param options.dataset - (Optional) The dataset configuration. * @param options.metrics - (Optional) List of server-side metrics to configure for the experiment. * @returns A promise that resolves to the created experiment. */ createExperiment(options: { name: string; projectId?: string; projectName?: string; dataset?: ExperimentDatasetRequest | null; metrics?: (GalileoMetrics | string | Metric | LocalMetricConfig)[]; }): Promise; /** * Updates an experiment. * @param options - The options for updating an experiment. * @param options.id - The unique identifier of the experiment. * @param options.projectId - The unique identifier of the project. * @param options.updateRequest - The experiment update request. * @returns A promise that resolves to the updated experiment. */ updateExperiment(options: { id: string; projectId: string; updateRequest: ExperimentUpdateRequest; }): Promise; /** * Deletes an experiment. * @param options - The options for deleting an experiment. * @param options.id - The unique identifier of the experiment. * @param options.projectId - The unique identifier of the project. * @returns A promise that resolves when the experiment is deleted. */ deleteExperiment(options: { id: string; projectId: string; }): Promise; /** * Gets experiments for a project. * @param options - (Optional) The options for getting experiments. * @param options.projectId - (Optional) The unique identifier of the project. * @param options.projectName - (Optional) The name of the project. * @returns A promise that resolves to an array of experiments. */ getExperiments(options?: { projectId?: string; projectName?: string; }): Promise; /** * Processes a dataset row using a runner function. * @param row - The dataset row to process. * @param processFn - The runner function to use for processing. * @returns A promise that resolves to the processed output as a string. */ private processRow; /** * Gets the link to experiment results. * @param experimentId - The unique identifier of the experiment. * @param projectId - The unique identifier of the project. * @returns The URL to the experiment results. */ private getLinkToExperimentResults; /** * Runs an experiment by processing each row of a dataset using a runner function. * @param experiment - The experiment to run. * @param projectName - The name of the project. * @param dataset - The content of the dataset. * @param processFn - The runner function to use for processing. * @param localMetrics - (Optional) The local metrics to use for client-side evaluation. * @param projectId - (Optional) The unique identifier of the project. If not provided, a dummy value will be used for link generation. * @returns A promise that resolves to the experiment run output. */ runExperimentWithFunction>(experiment: ExperimentResponseType, projectName: string, dataset: DatasetRecord[], processFn: (input: T, metadata?: Record) => Promise, localMetrics?: LocalMetricConfig[], projectId?: string): Promise; /** * Runs an experiment by processing each row of a dataset through a specified function or prompt template. * If metrics are provided, they will be used to evaluate the experiment. * @param params - The experiment run parameters. * @param params.name - The name of the experiment. * @param params.function - The function to process each dataset row. Either function or promptTemplate must be provided. * @param params.promptTemplate - The prompt template to use. Either function or promptTemplate must be provided. * @param params.dataset - The dataset to process. Either dataset, datasetId, or datasetName must be provided. * @param params.datasetId - The id of the dataset to process. Either dataset, datasetId, or datasetName must be provided. * @param params.datasetName - The name of the dataset to process. Either dataset, datasetId, or datasetName must be provided. * @param params.metrics - (Optional) List of metrics to evaluate the experiment. * @param params.projectName - (Optional) The name of the project. * @param params.projectId - (Optional) The id of the project. * @param params.experimentTags - (Optional) Tags to associate with the experiment. * @param params.promptSettings - (Optional) Settings for prompt template execution. * @returns A promise that resolves to the experiment run output. */ runExperiment>(params: RunExperimentParams): Promise; private getExperimentProject; private validateExperimentName; private createNewExperiment; private configureExperimentTags; private configureExperimentMetrics; private loadExperimentData; private processExperimentFunction; private processExperimentPromptTemplate; }