Skip to content
1 min read · 205 words

Function: resolveGenerationOptions()

ts
function resolveGenerationOptions(
  canonical: ChatGenerationOptions,
  nativeFallbacks?: {
    enableThinking?: boolean;
    maxTokens?: number;
    multimodal?: {
      audio?: boolean;
      image?: boolean;
    };
    sampler?: ChatSampler;
    seed?: number;
    temperature?: number;
    topK?: number;
    topP?: number;
  },
): ResolvedGenerationOptions;

Defined in: src/batteries/llm/chat_common/generation.ts:109

Resolve the canonical ChatGenerationOptions (already merged across option layers) into a fully-defaulted ResolvedGenerationOptions. Native per-battery fallbacks are passed via nativeFallbacks and consulted ONLY when the canonical field is absent (canonical wins). The adapter then maps the resolved shape onto its runtime API.

Parameters

ParameterTypeDescription
canonicalChatGenerationOptionsThe canonical fields from the merged adapter options.
nativeFallbacks{ enableThinking?: boolean; maxTokens?: number; multimodal?: { audio?: boolean; image?: boolean; }; sampler?: ChatSampler; seed?: number; temperature?: number; topK?: number; topP?: number; }Battery-native equivalents to fall back to when a canonical field is unset (e.g. transformers.js maxNewTokens, LiteRT maxOutputTokens). Each is consulted second.
nativeFallbacks.enableThinking?boolean-
nativeFallbacks.maxTokens?number-
nativeFallbacks.multimodal?{ audio?: boolean; image?: boolean; }-
nativeFallbacks.multimodal.audio?boolean-
nativeFallbacks.multimodal.image?boolean-
nativeFallbacks.sampler?ChatSampler-
nativeFallbacks.seed?number-
nativeFallbacks.temperature?number-
nativeFallbacks.topK?number-
nativeFallbacks.topP?number-

Returns

ResolvedGenerationOptions