inferContextWindow (utils/contextWindow.ts)

agents-universe · packages/web/src/utils/contextWindow.ts · typescript · Apache-2.0
ai

Infers context window size for AI models based on provider and model ID, used for default settings.

// Source: https://github.com/agents-universe/agents-universe | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Name-matched context-window inference for user model configs.
 *
 * Best-effort default for the Settings → AI Models context-window field: the
 * provider would use this value at runtime when the config leaves the field
 * empty. Matching the same naming conventions as the Python originals:
 *   packages/agent-core/src/agent_core/providers/{openai,anthropic_claude,google_gemini}.py
 *   (_context_window) and packages/agent-core/src/agent_core/providers/registry.py
 *   (default_context_window) — keep all four in sync. Unrecognized models get
 *   the provider's cons

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key