@tanstack/ai
Version:
Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.
32 lines (31 loc) • 1.14 kB
JavaScript
//#region src/utilities/sampling-keys.ts
/**
* Single source of truth for the provider-native key spellings that cap output
* tokens. Sampling options live in opaque, provider-native `modelOptions`, and
* every provider spells the token cap differently. Two call sites must agree on
* this set or they silently drift:
*
* - `activities/summarize/chat-stream-summarize.ts` — detects a caller-supplied
* token limit so the summarize default never overrides it.
* - `middlewares/otel.ts` — picks the first numeric spelling to populate the
* `gen_ai.request.max_tokens` attribute across providers.
*
* Keep this list in lockstep with `MAX_TOKENS_KEY_BY_ADAPTER` (the adapter →
* native-key map) in the summarize wrapper.
*/
var MAX_TOKENS_KEYS = [
"max_output_tokens",
"max_tokens",
"max_completion_tokens",
"maxOutputTokens",
"maxCompletionTokens",
"maxTokens"
];
/**
* Ollama nests sampling under `options`; its token cap is `options.num_predict`
* rather than a flat key.
*/
var NESTED_MAX_TOKENS_KEY = "num_predict";
//#endregion
export { MAX_TOKENS_KEYS, NESTED_MAX_TOKENS_KEY };
//# sourceMappingURL=sampling-keys.js.map