Files
yvgude--lean-ctx/integrations/hermes-lean-ctx/presets.py
T
wehub-resource-sync 26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:30 +08:00

45 lines
1.2 KiB
Python

"""Best-effort model -> context-window presets.
Only a fallback: Hermes passes the real ``context_length`` to
``update_model``; these published windows are used when it does not. Matching
is by case-insensitive substring, longest key first (so ``gpt-4o-mini`` is not
shadowed by ``gpt-4``).
"""
from __future__ import annotations
from typing import Optional
# Conservative, widely-documented context windows.
_PRESETS = {
"claude": 200_000,
"claude-3": 200_000,
"claude-4": 200_000,
"gpt-4o": 128_000,
"gpt-4.1": 1_000_000,
"gpt-4-turbo": 128_000,
"gpt-4": 8_192,
"gpt-3.5": 16_385,
"o1": 200_000,
"o3": 200_000,
"hermes": 128_000,
"llama-3.1": 128_000,
"llama-3": 8_192,
"qwen2.5": 128_000,
"deepseek": 128_000,
"mistral": 32_768,
"gemini-1.5": 1_000_000,
"gemini": 1_000_000,
}
def context_length_for(model: Optional[str]) -> Optional[int]:
"""Return a known context window for ``model``, or ``None`` if unknown."""
if not model:
return None
needle = model.lower()
for key in sorted(_PRESETS, key=len, reverse=True):
if key in needle:
return _PRESETS[key]
return None