fix(llm-gateway): improve type safety and datetime consistency
- Add type annotations for mypy compliance - Use UTC-aware datetimes consistently (datetime.now(UTC)) - Add type: ignore comments for LiteLLM incomplete stubs - Fix import ordering and formatting - Update pyproject.toml mypy configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,9 +49,9 @@ def configure_litellm(settings: Settings) -> None:
|
||||
# Configure caching if enabled
|
||||
if settings.litellm_cache_enabled:
|
||||
litellm.cache = litellm.Cache(
|
||||
type="redis",
|
||||
type="redis", # type: ignore[arg-type]
|
||||
host=_parse_redis_host(settings.redis_url),
|
||||
port=_parse_redis_port(settings.redis_url),
|
||||
port=_parse_redis_port(settings.redis_url), # type: ignore[arg-type]
|
||||
ttl=settings.litellm_cache_ttl,
|
||||
)
|
||||
|
||||
@@ -115,10 +115,7 @@ def _build_model_entry(
|
||||
}
|
||||
|
||||
# Add custom base URL for DeepSeek self-hosted
|
||||
if (
|
||||
model_config.provider == Provider.DEEPSEEK
|
||||
and settings.deepseek_base_url
|
||||
):
|
||||
if model_config.provider == Provider.DEEPSEEK and settings.deepseek_base_url:
|
||||
entry["litellm_params"]["api_base"] = settings.deepseek_base_url
|
||||
|
||||
return entry
|
||||
@@ -269,7 +266,7 @@ class LLMProvider:
|
||||
# Create Router
|
||||
self._router = Router(
|
||||
model_list=model_list,
|
||||
fallbacks=list(fallbacks.items()) if fallbacks else None,
|
||||
fallbacks=list(fallbacks.items()) if fallbacks else None, # type: ignore[arg-type]
|
||||
routing_strategy="latency-based-routing",
|
||||
num_retries=self._settings.litellm_max_retries,
|
||||
timeout=self._settings.litellm_timeout,
|
||||
|
||||
Reference in New Issue
Block a user