/**
 * Copyright 2026 The ODML Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { ModelInput } from './model_input.js';
import { SpeculativeDecodingConfig } from './speculative_decoding_config.js';
import { RecursiveRequired } from './types.js';
import { ActivationDataType, type AdvancedSettings, Backend, type CpuConfig, EngineSettings as WasmEngineSettings, GpuArtisanConfig as WasmGpuArtisanConfig, type GpuConfig } from './wasm_binding_types.js';
export { ActivationDataType, AdvancedSettings, CpuConfig, GpuConfig };
/**
 * LiteRT-LM GpuArtisanConfig
 */
export interface GpuArtisanConfig extends Omit<WasmGpuArtisanConfig, 'supported_lora_ranks'> {
    supported_lora_ranks: number[];
}
/**
 * LiteRT-LM LlmExecutorSettings
 */
export interface LlmExecutorSettings {
    maxNumTokens?: number;
    /**
     * Maximum number of images in a conversation (until the context is reset).
     * Required for vision input with `Backend.GPU_ARTISAN` models, which reserve
     * space for this many images' embeddings up front.
     */
    maxNumImages?: number;
    backendConfig?: Partial<CpuConfig> | Partial<GpuConfig> | Partial<GpuArtisanConfig>;
    samplerBackend?: Backend;
    advancedSettings?: Partial<AdvancedSettings>;
}
/**
 * LiteRT-LM EngineSettings
 */
export interface EngineSettings {
    /** The model: a URL, a `hf://` URI, a `ModelSource`, or the model's data. */
    model: ModelInput;
    /**
     * Backend for the model. Defaults to `Backend.GPU`. For a model loaded from
     * a `hf://` URI, it also chooses the model file, and the model must use it
     * if it's set (see `ModelInput`).
     */
    backend?: Backend;
    /**
     * Activation precision for the text model on GPU backends (`Backend.GPU` and
     * `Backend.GPU_ARTISAN`), such as `ActivationDataType.FLOAT16` or
     * `ActivationDataType.FLOAT32`.
     *
     * If unset, the runtime uses the model section's preferred activation type if
     * present, or `ActivationDataType.FLOAT16` otherwise. Ignored on
     * `Backend.CPU`.
     */
    activationDataType?: ActivationDataType;
    /**
     * Backend for the vision encoder. Can be `Backend.CPU` or `Backend.GPU`.
     * If unset, vision input is disabled.
     */
    visionBackend?: Backend;
    /**
     * Activation precision for the vision encoder when `visionBackend` is
     * `Backend.GPU`, such as `ActivationDataType.FLOAT16` or
     * `ActivationDataType.FLOAT32`.
     *
     * If unset, the runtime uses the model section's preferred activation type if
     * present, or `ActivationDataType.FLOAT32` otherwise. Ignored when vision is
     * disabled or when `visionBackend` is `Backend.CPU`.
     */
    visionActivationDataType?: ActivationDataType;
    /**
     * Maximum number of vision tokens per image. Only used when vision is
     * enabled. If unset, the model's default is used.
     */
    maxVisionTokensPerImage?: number;
    /**
     * Smallest vision signature, in tokens per image, to prepare. Defaults to
     * `maxVisionTokensPerImage`, which prepares exactly one vision signature.
     *
     * Lowering this prepares additional smaller signatures so that small images
     * run on a tighter graph instead of being padded, but each extra signature
     * costs a lot of memory and can exceed the 4GB wasm32 limit.
     */
    minVisionTokensPerImage?: number;
    /**
     * Backend for the audio encoder. Can be `Backend.CPU` or `Backend.GPU`.
     * If unset, audio input is disabled.
     */
    audioBackend?: Backend;
    /**
     * Activation precision for the audio encoder when `audioBackend` is
     * `Backend.GPU`, such as `ActivationDataType.FLOAT16` or
     * `ActivationDataType.FLOAT32`.
     *
     * If unset, the runtime uses the model section's preferred activation type if
     * present, or `ActivationDataType.FLOAT32` otherwise. Ignored when audio is
     * disabled or when `audioBackend` is `Backend.CPU`.
     */
    audioActivationDataType?: ActivationDataType;
    mainExecutorSettings?: LlmExecutorSettings;
    benchmarkEnabled?: boolean;
    /**
     * The default speculative decoding (e.g. Multi-Token Prediction (MTP))
     * configuration of the engine's sessions. Each session can override any field
     * with `SessionConfig.speculativeDecodingConfig`. Fields left unset use the
     * runtime defaults (mode `SpeculativeDecodingMode.OFF`).
     *
     * Speculative decoding requires a model that contains a drafter, such as
     * Gemma 4 with an MTP drafter, and only supports a single output candidate.
     * Modes `ON` and `ADAPTIVE` load the drafter when the engine is created. If
     * the mode is `OFF`, the drafter is not loaded, and sessions can not enable
     * speculative decoding later.
     */
    speculativeDecodingConfig?: SpeculativeDecodingConfig;
}
type OptionalEngineSettingsKeys = 'activationDataType' | 'visionBackend' | 'visionActivationDataType' | 'maxVisionTokensPerImage' | 'minVisionTokensPerImage' | 'audioBackend' | 'audioActivationDataType' | 'speculativeDecodingConfig';
/**
 * EngineSettings with all defaults resolved. Fields that have no default
 * (e.g. vision settings when vision is disabled) remain optional.
 */
export type ResolvedEngineSettings = RecursiveRequired<Omit<EngineSettings, OptionalEngineSettingsKeys | 'model'>> & Pick<EngineSettings, OptionalEngineSettingsKeys | 'model'>;
/**
 * Fills a WasmEngineSettings with the values from a EngineSettings.
 */
export declare function fillWasmEngineSettingsFromEngineSettings(wasmEngineSettings: WasmEngineSettings, engineSettings: EngineSettings, backend: Backend, wasm?: import("./wasm_binding_types.js").LiteRtLmWasm): void;
/**
 * Converts a WasmEngineSettings to a EngineSettings.
 *
 * Fields are populated with the WASM object's values, which may be default
 * values if they were not set. Advanced settings that have not been set yet
 * (i.e. before the engine is created) are filled with the C++ defaults.
 *
 * The returned value omits the `model` field since its TS representation is a
 * URL or stream, which does not match what the WASM object holds.
 */
export declare function wasmEngineSettingsToEngineSettings(wasmEngineSettings: WasmEngineSettings, wasm?: import("./wasm_binding_types.js").LiteRtLmWasm): Omit<ResolvedEngineSettings, 'model'>;
//# sourceMappingURL=engine_settings.d.ts.map