feat: add embedding types, port and openai-compat transport
This commit is contained in:
@@ -10,7 +10,14 @@ from dataclasses import dataclass
|
||||
from enum import StrEnum
|
||||
from typing import Any, Protocol, runtime_checkable
|
||||
|
||||
from .types import ChatRequest, LLMResponse, SourceConfig, SourceStats, TransportResult
|
||||
from .types import (
|
||||
ChatRequest,
|
||||
EmbeddingTransportResult,
|
||||
LLMResponse,
|
||||
SourceConfig,
|
||||
SourceStats,
|
||||
TransportResult,
|
||||
)
|
||||
|
||||
CallNext = Callable[[ChatRequest], Awaitable[LLMResponse]]
|
||||
|
||||
@@ -37,6 +44,15 @@ class Transport(Protocol):
|
||||
) -> TransportResult: ...
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class EmbeddingTransport(Protocol):
|
||||
"""一次原始 embedding 调用的协议细节(M2 §7);不含任何治理。"""
|
||||
|
||||
async def embed(
|
||||
self, *, texts: list[str], source: SourceConfig, call_id: str
|
||||
) -> EmbeddingTransportResult: ...
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class Permit(Protocol):
|
||||
"""限流入场许可;settle/release 均幂等,finally 中必然执行。"""
|
||||
|
||||
Reference in New Issue
Block a user