feat: 支持 Completions/Responses 双协议,并在同选型下续链加速

This commit is contained in:
2026-09-24 17:10:34 +08:00
parent 9c2c1ed061
commit d20c6a1302
26 changed files with 533 additions and 43 deletions
@@ -9,6 +9,7 @@ import redis.asyncio as redis
from config.settings import Settings
from domain.models import LlmRuntimeConfig
from domain.ports import LlmRuntimeCache
from infrastructure.llm.api_style import normalize_api_style
class RedisLlmRuntimeCache(LlmRuntimeCache):
@@ -43,6 +44,7 @@ class RedisLlmRuntimeCache(LlmRuntimeCache):
provider_id=_optional_int(data.get("provider_id")) or provider_id,
extra_headers=data.get("extra_headers") or {},
context_window=_optional_int(data.get("context_window")),
api_style=normalize_api_style(data.get("api_style")),
)
if model and cfg.model and cfg.model != model:
return None
@@ -63,6 +65,7 @@ class RedisLlmRuntimeCache(LlmRuntimeCache):
"model": config.model,
"extra_headers": config.extra_headers,
"context_window": config.context_window,
"api_style": normalize_api_style(config.api_style),
}
await self._r.set(
self._key(company_id, config.provider_id, config.model),