import type { components } from "../generated/api-types"; import type { ModelCollaborators } from "../models/types"; export interface OutputModel { name: string; collaborators: ModelCollaborators; description?: string; tags?: string[]; license_id?: string; } /** * A destination connection to create for the model produced by a training run. */ export interface NewModelConnection { /** Destination-specific quick settings; shape depends on the destination app. */ quick_settings?: Record; /** UUID of the app profile backing the connection. */ profile_id: string; } export interface TrainModelRequest { base_model_id: number; dataset_id: number; training_config: ModelTrainingConfig; output_model: OutputModel; /** * Connections to create for the trained model. Optional until the UI supports * adding connections when kicking off training runs. */ connections?: NewModelConnection[]; } export interface TrainModelResponse { job_id: string; } export interface ModelTrainingConfig { instance_type: string; /** Free-form JSON override merged into the generated Axolotl config (Scala `Option[Json]`). */ custom_axolotl_config_override?: Record; } /** * Free-form settings passed straight through to the training procedure, which * validates them. * * The backend types every one of these as a bare `Json`, which the spec writes * as `type: object` and the generator renders as `Record` — a * type no object literal satisfies, so a caller could not fill one in. Widened * here so `{ type: "random_forest", n_estimators: 200 }` compiles. */ export type ClassifierSettings = Record; /** Fields every feature shares. */ interface FeatureInputBase { /** * Column the feature is read from: either a plain column name or a path into * a variant column, e.g. `data['merchant']`. Must exist in the dataset's * schema, spelled exactly as it appears there. */ field_path: string; /** Unique within the request. Alphanumerics and underscores only. */ name: string; } export interface CategoricalFeatureInput extends FeatureInputBase { feature_type: "categorical"; /** The only variant that reads `field_type` — the others fix it themselves. */ field_type: "boolean" | "number" | "string"; /** Encoding settings, e.g. `{ max_categories: 100 }`. */ categorical?: ClassifierSettings; /** Preprocessing applied before encoding. */ preprocess?: ClassifierSettings[]; } export interface EmbeddingFeatureInput extends FeatureInputBase { feature_type: "embedding"; /** e.g. `{ model: "e5-base-v2" }`. */ embedding?: ClassifierSettings; } export interface NumericFeatureInput extends FeatureInputBase { feature_type: "numeric"; /** e.g. `{ scaler: "standard" }`. */ numeric?: ClassifierSettings; } export interface TextFeatureInput extends FeatureInputBase { feature_type: "text"; /** e.g. `{ max_features: 10000 }`. */ tfidf?: ClassifierSettings; } /** * How one column is encoded for training, discriminated on `feature_type`. * * Hand-written rather than aliased. The backend models this as a sealed trait * with four variants, each carrying its own settings key, and only * `categorical` reads `field_type` — the other three fix it (`array`, `number`, * `string`) and ignore whatever is sent. The spec flattens all four into one * object with every key optional, which describes none of them: it would accept * a `text` feature carrying `numeric` settings, and reject nothing that matters. */ export type FeatureInput = CategoricalFeatureInput | EmbeddingFeatureInput | NumericFeatureInput | TextFeatureInput; /** * Body of `POST /v1/model-training/train-classifier`. * * Aliased from the generated schema except for `feature_inputs` and `model`. * The backend takes a `NonEmptyList[FeatureInput]`, so the tuple below turns an * empty array into a compile error rather than a 400. */ export type TrainClassifierRequest = Omit & { feature_inputs: [FeatureInput, ...FeatureInput[]]; /** Classifier hyperparameters. Defaults to logistic regression. */ model?: ClassifierSettings; }; export type TrainClassifierResponse = components["schemas"]["TrainClassifierResponse"]; export {};