mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 02:29:19 +08:00
fix: 探测 Responses/store 能力并在无状态时用 Completions 带全量历史
This commit is contained in:
@@ -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。"""
|
||||
|
||||
@@ -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):
|
||||
"""流式生成助手回复。"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user