from dataclasses import dataclass
import os


@dataclass(frozen=True)
class GigaChatSettings:
    auth_url: str
    api_url: str
    scope: str
    credentials: str
    ssl_verify: bool
    model: str
    embedding_model: str

    @classmethod
    def from_env(cls) -> "GigaChatSettings":
        return cls(
            auth_url=os.getenv("GIGACHAT_AUTH_URL", "https://ngw.devices.sberbank.ru:9443/api/v2/oauth"),
            api_url=os.getenv("GIGACHAT_API_URL", "https://gigachat.devices.sberbank.ru/api/v1"),
            scope=os.getenv("GIGACHAT_SCOPE", "GIGACHAT_API_PERS"),
            credentials=os.getenv("GIGACHAT_TOKEN", "").strip(),
            ssl_verify=os.getenv("GIGACHAT_SSL_VERIFY", "true").lower() in {"1", "true", "yes"},
            model=os.getenv("GIGACHAT_MODEL", "GigaChat"),
            embedding_model=os.getenv("GIGACHAT_EMBEDDING_MODEL", "Embeddings"),
        )
