"""模型供应商适配层，Agent Kernel 不直接依赖 DeepSeek SDK 配置。"""

from typing import Protocol

from langchain_core.language_models.chat_models import BaseChatModel
from langchain_openai import ChatOpenAI
from pydantic import SecretStr

from zbt.core.config import Settings


class ModelGateway(Protocol):
    def chat_model(self, persona: str) -> BaseChatModel: ...


class DeepSeekModelGateway:
    """通过 OpenAI 兼容协议连接真实 DeepSeek。"""

    def __init__(self, settings: Settings) -> None:
        self._settings = settings

    def chat_model(self, persona: str) -> BaseChatModel:
        del persona
        return ChatOpenAI(
            model=self._settings.deepseek_model,
            api_key=SecretStr(self._settings.deepseek_api_key),
            base_url=self._settings.deepseek_base_url,
            temperature=0,
            max_retries=2,
            timeout=60,
        )
