import type { Dataset, DatasetExample, DatasetStore, Experiment, ExperimentStore } from '../types/evaluate.js'; import type { Run, RunQuery, TraceStore } from '../types/tracing.js'; import { contentVersion } from './version.js'; export { contentVersion }; /** Options for `createDataset()`. */ export interface CreateDatasetOptions { /** The dataset's name. */ name: string; /** The examples. Those without an id are numbered `ex-1`, `ex-2`, and so on. */ examples: Array, 'id'> & { id?: string; }>; /** What the dataset is for. */ description?: string; /** Labels for filtering. */ tags?: string[]; /** Defaults to a hash of the examples, so identical content is the same version. */ version?: string; /** Replaces the system clock, for `createdAt`. */ now?: () => Date; } /** * Builds a dataset, versioned by its content. * * A version derived from the examples means two experiments can be compared only when they really * ran over the same data: change an example and the version changes with it, rather than silently * invalidating every earlier comparison. */ export declare function createDataset(options: CreateDatasetOptions): Dataset; /** Examples of one split, as a dataset in its own right. */ export declare function splitOf(dataset: Dataset, split: string): Dataset; /** Options for `datasetFromTraces()`. */ export interface FromTracesOptions { /** The dataset's name. */ name: string; /** Where the runs are. */ store: TraceStore; /** Which runs to use. */ query?: RunQuery; /** Turns a run into an example. Defaults to its inputs and outputs. */ toExample?: (run: Run) => Omit | undefined; /** Most runs read. Defaults to 100. */ limit?: number; } /** * Builds a dataset from recorded production runs. * * The most valuable examples are the ones that already happened: the request that failed, the answer * a user marked wrong. Each example keeps `sourceRunId`, so a result can always be traced back to * the run it came from. */ export declare function datasetFromTraces(options: FromTracesOptions): Promise; /** Datasets in memory, keyed by name and version. */ export declare class MemoryDatasetStore implements DatasetStore { private readonly datasets; /** Saves a dataset version. */ save(dataset: Dataset): void; /** Returns a version, or the newest when none is given. */ get(name: string, version?: string): Dataset | undefined; /** Every dataset name with its versions. */ list(): Array<{ name: string; versions: string[]; }>; } /** * Datasets as JSON files in a directory, one file per version. * * Readable, diffable, and reviewable: a dataset belongs in version control next to the code it * tests, which a database row does not allow. */ export declare class FileDatasetStore implements DatasetStore { private readonly directory; constructor(directory: string); /** Writes a dataset version to its file. */ save(dataset: Dataset): Promise; /** Returns a version, or the newest when none is given. */ get(name: string, version?: string): Promise; /** Every dataset name with its versions, from the file names. */ list(): Promise>; private read; private fileOf; } /** * Experiments as JSON files in a directory, one file per experiment. * * What a CI job wants: the baseline is a file the pipeline can cache or commit, and the candidate is * a file the next step can compare against it. */ export declare class FileExperimentStore implements ExperimentStore { private readonly directory; constructor(directory: string); /** Writes an experiment to its file. */ save(experiment: Experiment): Promise; /** Reads an experiment by id. */ get(id: string): Promise; /** Experiments, newest first, filtered by name or dataset. Defaults to 50. */ list(filter?: { name?: string; dataset?: string; limit?: number; }): Promise; private fileOf; } /** Reads an experiment file, or `undefined` when it is missing or is not an experiment. */ export declare function readExperiment(file: string): Promise; /** Experiments in memory, newest first. */ export declare class MemoryExperimentStore implements ExperimentStore { private readonly experiments; /** Saves an experiment. */ save(experiment: Experiment): void; /** Reads an experiment by id. */ get(id: string): Experiment | undefined; /** Experiments, newest first, filtered by name or dataset. Defaults to 50. */ list(filter?: { name?: string; dataset?: string; limit?: number; }): Experiment[]; }