refactor: Centralize strix model resolution with separate API and capability names

- Replace fragile prefix matching with explicit STRIX_MODEL_MAP
- Add resolve_strix_model() returning (api_model, canonical_model)
- api_model (openai/ prefix) for API calls to OpenAI-compatible Strix API
- canonical_model (actual provider name) for litellm capability lookups
- Centralize resolution in LLMConfig instead of scattered call sites
This commit is contained in:
0xallam
2026-02-20 04:40:04 -08:00
parent d2c99ea4df
commit 3b3576b024
6 changed files with 45 additions and 42 deletions
+3 -6
View File
@@ -4,7 +4,6 @@ from typing import Any
import litellm
from strix.config.config import Config, resolve_llm_config
from strix.llm.utils import get_litellm_model_name
logger = logging.getLogger(__name__)
@@ -46,8 +45,7 @@ keeping the summary concise and to the point."""
def _count_tokens(text: str, model: str) -> int:
try:
litellm_model = get_litellm_model_name(model) or model
count = litellm.token_counter(model=litellm_model, text=text)
count = litellm.token_counter(model=model, text=text)
return int(count)
except Exception:
logger.exception("Failed to count tokens")
@@ -109,9 +107,8 @@ def _summarize_messages(
_, api_key, api_base = resolve_llm_config()
try:
litellm_model = get_litellm_model_name(model) or model
completion_args: dict[str, Any] = {
"model": litellm_model,
"model": model,
"messages": [{"role": "user", "content": prompt}],
"timeout": timeout,
}
@@ -161,7 +158,7 @@ class MemoryCompressor:
):
self.max_images = max_images
self.model_name = model_name or Config.get("strix_llm")
self.timeout = timeout or int(Config.get("strix_memory_compressor_timeout") or "30")
self.timeout = timeout or int(Config.get("strix_memory_compressor_timeout") or "120")
if not self.model_name:
raise ValueError("STRIX_LLM environment variable must be set and not empty")