Skip to content
10 min read · 1,908 words

Interface: WebLLMChatCompletionsAdapterOptions

Defined in: batteries/llm/webllm_chat_completions/types.ts:54

Extends

Properties

PropertyTypeDefault valueDescriptionInherited fromDefined in
audio?{ format: "wav" | "mp3" | "flac" | "opus" | "pcm16"; voice: string; }undefined-OpenAIChatCompletionsAdapterOptions.audiobatteries/llm/openai_chat_completions/types.ts:545
audio.format"wav" | "mp3" | "flac" | "opus" | "pcm16"undefined--batteries/llm/openai_chat_completions/types.ts:545
audio.voicestringundefined--batteries/llm/openai_chat_completions/types.ts:545
autoAck?booleanfalseWhether the executor should call ctx.ack() itself when a generation completes with no tool calls (a terminal text answer). Remarks ack() is terminal and one-shot: once called, the dispatch loop exits after the current iteration. When the executor acks automatically, it seizes turn-completion control from the implementor — a dispatchOutputPipeline quality gate can never run, because the signal is already set before the output pipeline executes. This option therefore defaults to false (opt-in). With autoAck: false, a tool-call-free response leaves the context unsignalled and the executor returns; the implementor's output pipeline (or a later iteration) is responsible for calling ctx.ack() / ctx.nack(). This is the seam that makes output-side quality gates (citation enforcement, schema validation, regenerate-on-reject) possible. Set autoAck: true to restore single-shot behavior: the executor acks the moment a tool-call-free answer finishes, terminating the turn without giving the output pipeline a vote. The tool-call path is unaffected by this flag — it always withholds ack so the runner can iterate and execute the calls. Error paths always nack regardless of this flag.OpenAIChatCompletionsAdapterOptions.autoAckbatteries/llm/openai_chat_completions/types.ts:541
bucketOrder?ChatCompletionsBucketOrderundefined-OpenAIChatCompletionsAdapterOptions.bucketOrderbatteries/llm/openai_chat_completions/types.ts:444
chatOptions?ChatOptions | ChatOptions[]undefined--batteries/llm/webllm_chat_completions/types.ts:63
contextWindow?numberundefined-OpenAIChatCompletionsAdapterOptions.contextWindowbatteries/llm/openai_chat_completions/types.ts:445
createEngine?(input: { chatOptions?: ChatOptions | ChatOptions[]; engineConfig?: MLCEngineConfig; model: string; onInitProgress?: (report: InitProgressReport) => void; }) => Promise<MLCEngineInterface>undefined--batteries/llm/webllm_chat_completions/types.ts:64
engine?MLCEngineInterfaceundefined--batteries/llm/webllm_chat_completions/types.ts:61
engineConfig?MLCEngineConfigundefined--batteries/llm/webllm_chat_completions/types.ts:62
extra_body?Record<string, unknown>undefined--batteries/llm/webllm_chat_completions/types.ts:60
frequency_penalty?numberundefined-OpenAIChatCompletionsAdapterOptions.frequency_penaltybatteries/llm/openai_chat_completions/types.ts:546
function_call?| "auto" | "none" | { name: string; }undefined-OpenAIChatCompletionsAdapterOptions.function_callbatteries/llm/openai_chat_completions/types.ts:547
functions?{ description?: string; name: string; parameters?: JsonSchema; }[]undefined-OpenAIChatCompletionsAdapterOptions.functionsbatteries/llm/openai_chat_completions/types.ts:548
helpers?Partial<ChatCompletionsHelpers>undefined-OpenAIChatCompletionsAdapterOptions.helpersbatteries/llm/openai_chat_completions/types.ts:469
ignore_eos?booleanundefined--batteries/llm/webllm_chat_completions/types.ts:59
isWebGPUAvailable?() => booleanundefined--batteries/llm/webllm_chat_completions/types.ts:71
logit_bias?Record<string, number>undefined-OpenAIChatCompletionsAdapterOptions.logit_biasbatteries/llm/openai_chat_completions/types.ts:549
logprobs?booleanundefined-OpenAIChatCompletionsAdapterOptions.logprobsbatteries/llm/openai_chat_completions/types.ts:550
max_completion_tokens?numberundefined-OpenAIChatCompletionsAdapterOptions.max_completion_tokensbatteries/llm/openai_chat_completions/types.ts:551
max_tokens?numberundefined-OpenAIChatCompletionsAdapterOptions.max_tokensbatteries/llm/openai_chat_completions/types.ts:552
metadata?Record<string, string>undefined-OpenAIChatCompletionsAdapterOptions.metadatabatteries/llm/openai_chat_completions/types.ts:553
modalities?("text" | "audio")[]undefined-OpenAIChatCompletionsAdapterOptions.modalitiesbatteries/llm/openai_chat_completions/types.ts:554
modelstringundefined-OpenAIChatCompletionsAdapterOptions.modelbatteries/llm/openai_chat_completions/types.ts:544
n?numberundefined-OpenAIChatCompletionsAdapterOptions.nbatteries/llm/openai_chat_completions/types.ts:555
onInitProgress?(report: InitProgressReport) => voidundefined--batteries/llm/webllm_chat_completions/types.ts:70
parallel_tool_calls?booleanundefined-OpenAIChatCompletionsAdapterOptions.parallel_tool_callsbatteries/llm/openai_chat_completions/types.ts:556
prediction?{ content: | string | { text: string; type: "text"; }[]; type: "content"; }undefined-OpenAIChatCompletionsAdapterOptions.predictionbatteries/llm/openai_chat_completions/types.ts:557
prediction.content| string | { text: string; type: "text"; }[]undefined--batteries/llm/openai_chat_completions/types.ts:559
prediction.type"content"undefined--batteries/llm/openai_chat_completions/types.ts:558
presence_penalty?numberundefined-OpenAIChatCompletionsAdapterOptions.presence_penaltybatteries/llm/openai_chat_completions/types.ts:561
prompt_cache_key?stringundefined-OpenAIChatCompletionsAdapterOptions.prompt_cache_keybatteries/llm/openai_chat_completions/types.ts:562
prompt_cache_retention?"in_memory" | "24h"undefined-OpenAIChatCompletionsAdapterOptions.prompt_cache_retentionbatteries/llm/openai_chat_completions/types.ts:563
reasoning_effort?"low" | "high" | "minimal" | "medium"undefined-OpenAIChatCompletionsAdapterOptions.reasoning_effortbatteries/llm/openai_chat_completions/types.ts:564
reasoningFieldPrecedence?ReasoningFieldPrecedence['reasoning', 'reasoning_content']Ordered precedence of the wire fields the adapter reads for model reasoning/thinking output. Remarks Reasoning is not part of OpenAI's official Chat Completions spec, so OpenAI-compatible providers disagree on the field name: Ollama's /v1 and current vLLM emit reasoning, while legacy vLLM (≤0.8) and the DeepSeek API emit reasoning_content. The adapter reads every field in this list that is present on the response. Precedence governs two things. When more than one listed field is present with identical content (or only one is present), the adapter emits a single thought attributed to the highest-precedence field. When listed fields are present with divergent content, each surfaces as its own thought (ordered by precedence) rather than silently dropping one — a thought stream is the wrong place to lose data.OpenAIChatCompletionsAdapterOptions.reasoningFieldPrecedencebatteries/llm/openai_chat_completions/types.ts:468
repetition_penalty?numberundefined--batteries/llm/webllm_chat_completions/types.ts:58
replayCompatibility?readonly string[]undefined-OpenAIChatCompletionsAdapterOptions.replayCompatibilitybatteries/llm/openai_chat_completions/types.ts:449
response_format?| { type: "text"; } | { type: "json_object"; } | { json_schema: { description?: string; name: string; schema: JsonSchema; strict?: boolean; }; type: "json_schema"; }undefined-OpenAIChatCompletionsAdapterOptions.response_formatbatteries/llm/openai_chat_completions/types.ts:565
safety_identifier?stringundefined-OpenAIChatCompletionsAdapterOptions.safety_identifierbatteries/llm/openai_chat_completions/types.ts:577
seed?numberundefined-OpenAIChatCompletionsAdapterOptions.seedbatteries/llm/openai_chat_completions/types.ts:578
selfIdentity?stringundefined-OpenAIChatCompletionsAdapterOptions.selfIdentitybatteries/llm/openai_chat_completions/types.ts:446
service_tier?"default" | "auto" | "flex" | "priority" | "scale"undefined-OpenAIChatCompletionsAdapterOptions.service_tierbatteries/llm/openai_chat_completions/types.ts:579
spoolStore?SpoolStorea new InMemorySpoolStore per dispatchBacking store for string / Uint8Array tool returns. Tool output bytes are written under the tool call's id; the resulting @nhtio/adk!SpooledArtifact (or the tool's configured subclass) is the model-visible handle for the rest of the turn. Remarks Defaults to a fresh, ephemeral per-dispatch @nhtio/adk/batteries/storage/in_memory!InMemorySpoolStore. Inject an @nhtio/adk/batteries/storage/opfs!OpfsSpoolStore or a Flydrive-backed store to persist artifacts to durable storage (and to stream large/binary tool output to disk rather than buffering it in memory). Lifetime / namespacing: the default store is per-dispatch, so tool-call ids only need to be unique within a dispatch. An injected durable store persists across turns and dispatches, so the tool-call ids used as keys must be globally unique for that store (or the store must apply its own keyPrefix); the adapter does not namespace keys for you, and it does not delete entries — lifetime and cleanup of an injected store are the consumer's responsibility.OpenAIChatCompletionsAdapterOptions.spoolStorebatteries/llm/openai_chat_completions/types.ts:490
stop?string | string[]undefined-OpenAIChatCompletionsAdapterOptions.stopbatteries/llm/openai_chat_completions/types.ts:580
store?booleanundefined-OpenAIChatCompletionsAdapterOptions.storebatteries/llm/openai_chat_completions/types.ts:581
stream?booleanundefined-OpenAIChatCompletionsAdapterOptions.streambatteries/llm/openai_chat_completions/types.ts:439
stream_options?{ include_obfuscation?: boolean; include_usage?: boolean; }undefined-OpenAIChatCompletionsAdapterOptions.stream_optionsbatteries/llm/openai_chat_completions/types.ts:582
stream_options.include_obfuscation?booleanundefined--batteries/llm/openai_chat_completions/types.ts:582
stream_options.include_usage?booleanundefined--batteries/llm/openai_chat_completions/types.ts:582
streamIdleTimeoutMs?numberundefined-OpenAIChatCompletionsAdapterOptions.streamIdleTimeoutMsbatteries/llm/openai_chat_completions/types.ts:440
strictToolChoice?booleanfalseWhen tool_choice (or the allowed_tools variant) forces the model onto a specific tool name, and that name resolves to an ephemeral, forged artifact-query tool (one produced by <Subclass>.forgeTools(ctx) — i.e. tool.ephemeral === true), this flag controls how the adapter reacts: - false (default): emit a single helpers.log.warn({ kind: 'tool-choice-forged-artifact', ... }) record and continue. Forging an artifact-query tool by name is almost always a misconfiguration — the tool may not exist in the next iteration once the artifact ages out — but the call still goes through. - true: hard-fail with E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONS. Use this in production deployments where forcing a forged tool indicates a real bug.OpenAIChatCompletionsAdapterOptions.strictToolChoicebatteries/llm/openai_chat_completions/types.ts:506
temperature?numberundefined-OpenAIChatCompletionsAdapterOptions.temperaturebatteries/llm/openai_chat_completions/types.ts:583
thoughtSurfacing?"all-self" | "latest-self" | "all"undefined-OpenAIChatCompletionsAdapterOptions.thoughtSurfacingbatteries/llm/openai_chat_completions/types.ts:447
tokenEncoding?| "gpt2" | "r50k_base" | "p50k_base" | "p50k_edit" | "cl100k_base" | "o200k_base" | "gemini" | "llama2" | "claude" | nullundefined-OpenAIChatCompletionsAdapterOptions.tokenEncodingbatteries/llm/openai_chat_completions/types.ts:448
tool_choice?| "required" | "auto" | "none" | { function: { name: string; }; type: "function"; } | { custom: { name: string; }; type: "custom"; } | { allowed_tools: { mode: "required" | "auto"; tools: ( | { function: { name: string; }; type: "function"; } | { custom: { name: string; }; type: "custom"; })[]; }; type: "allowed_tools"; }undefined-OpenAIChatCompletionsAdapterOptions.tool_choicebatteries/llm/openai_chat_completions/types.ts:584
top_logprobs?numberundefined-OpenAIChatCompletionsAdapterOptions.top_logprobsbatteries/llm/openai_chat_completions/types.ts:600
top_p?numberundefined-OpenAIChatCompletionsAdapterOptions.top_pbatteries/llm/openai_chat_completions/types.ts:601
unsupportedMediaPolicy?UnsupportedMediaPolicy'throw'Policy for how the adapter handles a @nhtio/adk!Media instance whose modality the OpenAI Chat Completions wire format does not natively support (today: video). See UnsupportedMediaPolicy.OpenAIChatCompletionsAdapterOptions.unsupportedMediaPolicybatteries/llm/openai_chat_completions/types.ts:515
user?stringundefined-OpenAIChatCompletionsAdapterOptions.userbatteries/llm/openai_chat_completions/types.ts:602
verbosity?"low" | "high" | "medium"undefined-OpenAIChatCompletionsAdapterOptions.verbositybatteries/llm/openai_chat_completions/types.ts:603
web_search_options?{ search_context_size?: "low" | "high" | "medium"; user_location?: { approximate: { city?: string; country?: string; region?: string; timezone?: string; }; type: "approximate"; }; }undefined-OpenAIChatCompletionsAdapterOptions.web_search_optionsbatteries/llm/openai_chat_completions/types.ts:604
web_search_options.search_context_size?"low" | "high" | "medium"undefined--batteries/llm/openai_chat_completions/types.ts:605
web_search_options.user_location?{ approximate: { city?: string; country?: string; region?: string; timezone?: string; }; type: "approximate"; }undefined--batteries/llm/openai_chat_completions/types.ts:606
web_search_options.user_location.approximate{ city?: string; country?: string; region?: string; timezone?: string; }undefined--batteries/llm/openai_chat_completions/types.ts:608
web_search_options.user_location.approximate.city?stringundefined--batteries/llm/openai_chat_completions/types.ts:609
web_search_options.user_location.approximate.country?stringundefined--batteries/llm/openai_chat_completions/types.ts:610
web_search_options.user_location.approximate.region?stringundefined--batteries/llm/openai_chat_completions/types.ts:611
web_search_options.user_location.approximate.timezone?stringundefined--batteries/llm/openai_chat_completions/types.ts:612
web_search_options.user_location.type"approximate"undefined--batteries/llm/openai_chat_completions/types.ts:607