mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 23:47:54 +08:00
core/lmproto: add kind property to all clients + AnyLLMClient type
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
"""Agent-level type aliases for LLM client dispatch."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from plyngent.lmproto.anthropic.client import AnthropicClient
|
||||||
|
from plyngent.lmproto.deepseek.openai_compat.client import DeepseekOpenAIClient
|
||||||
|
from plyngent.lmproto.openai.client import OpenAIClient
|
||||||
|
from plyngent.lmproto.openai_compatible.client import OpenAICompatibleClient
|
||||||
|
|
||||||
|
type AnyLLMClient = OpenAICompatibleClient | DeepseekOpenAIClient | OpenAIClient | AnthropicClient
|
||||||
@@ -30,6 +30,8 @@ def _inject_thinking(data: bytes) -> bytes:
|
|||||||
|
|
||||||
|
|
||||||
class DeepseekOpenAIClient(BaseOpenAIClient):
|
class DeepseekOpenAIClient(BaseOpenAIClient):
|
||||||
|
kind: str = "chat_completions"
|
||||||
|
|
||||||
def __init__(self, config: OpenAIConfig) -> None:
|
def __init__(self, config: OpenAIConfig) -> None:
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ if TYPE_CHECKING:
|
|||||||
class OpenAIClient(BaseOpenAIClient):
|
class OpenAIClient(BaseOpenAIClient):
|
||||||
"""Full OpenAI HTTP client (``/chat/completions`` + ``/responses`` + ``/models``)."""
|
"""Full OpenAI HTTP client (``/chat/completions`` + ``/responses`` + ``/models``)."""
|
||||||
|
|
||||||
|
kind: str = "responses"
|
||||||
|
|
||||||
response_decoder: msgspec.json.Decoder[Response]
|
response_decoder: msgspec.json.Decoder[Response]
|
||||||
response_deleted_decoder: msgspec.json.Decoder[ResponseDeleted]
|
response_deleted_decoder: msgspec.json.Decoder[ResponseDeleted]
|
||||||
response_event_decoder: msgspec.json.Decoder[ResponseStreamEvent]
|
response_event_decoder: msgspec.json.Decoder[ResponseStreamEvent]
|
||||||
|
|||||||
@@ -180,6 +180,8 @@ class BaseOpenAIClient:
|
|||||||
class OpenAICompatibleClient(BaseOpenAIClient):
|
class OpenAICompatibleClient(BaseOpenAIClient):
|
||||||
"""Chat Completions only (``POST /chat/completions`` + ``GET /models``)."""
|
"""Chat Completions only (``POST /chat/completions`` + ``GET /models``)."""
|
||||||
|
|
||||||
|
kind: str = "chat_completions"
|
||||||
|
|
||||||
def __init__(self, config: OpenAIConfig) -> None:
|
def __init__(self, config: OpenAIConfig) -> None:
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user