# #region resolve_provider_model [C:2] [TYPE Function] [SEMANTICS llm, provider, model, resolve]
# @BRIEF Resolve the LLM provider model name for a translation job.
# @RELATION DEPENDS_ON -> [LLMProviderService]
from sqlalchemy.orm import Session

from ...models.translate import TranslationJob


def resolve_provider_model(db: Session, job: TranslationJob) -> str | None:
    """Resolve the default model name for the job's LLM provider. Returns None if not configured."""
    if job.provider_id:
        try:
            from ...services.llm_provider import LLMProviderService

            provider_svc = LLMProviderService(db)
            provider = provider_svc.get_provider(job.provider_id)
            if provider:
                return provider.default_model or "gpt-4o-mini"
        except Exception:
            pass
    return None


# #endregion resolve_provider_model
