fix: 探测 Responses/store 能力并在无状态时用 Completions 带全量历史

This commit is contained in:
2026-09-25 00:23:28 +08:00
parent d20c6a1302
commit 71eca63461
14 changed files with 584 additions and 193 deletions
+8
View File
@@ -133,6 +133,14 @@ class LlmRuntimeConfig:
api_style: str = "auto"
@dataclass(frozen=True)
class LlmProtocolCapability:
"""按提供商缓存的协议能力;None 表示尚未验证。"""
responses: bool | None = None
store: bool | None = None
@dataclass(frozen=True)
class StreamEvent:
"""流式片段:正文 token、服务端工具状态、或需前端执行的 client tool。"""
+27 -1
View File
@@ -5,7 +5,14 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, AsyncIterator
from domain.models import ChatMessage, LlmRuntimeConfig, Session, StreamEvent, UserMemory
from domain.models import (
ChatMessage,
LlmProtocolCapability,
LlmRuntimeConfig,
Session,
StreamEvent,
UserMemory,
)
class SessionRepository(ABC):
@@ -111,6 +118,25 @@ class LlmRuntimeGateway(ABC):
) -> LlmRuntimeConfig | None: ...
class LlmProtocolCapabilityCache(ABC):
"""缓存某提供商(或 base_url)是否支持 Responses / store。"""
@abstractmethod
async def get(
self, *, provider_id: int | None, base_url: str
) -> LlmProtocolCapability | None: ...
@abstractmethod
async def set(
self,
*,
provider_id: int | None,
base_url: str,
capability: LlmProtocolCapability,
ttl_seconds: int,
) -> None: ...
class ChatStreamer(ABC):
"""流式生成助手回复。"""