from __future__ import annotations

from collections.abc import Mapping
from typing import Any

from app.llm.contracts import LLMTask
from app.llm.models import LLMTextRequest, LLMTextResult


def generate_task_text(
    llm_router: Any,
    *,
    task: LLMTask,
    prompt: str,
    system_prompt: str | None = None,
    metadata: Mapping[str, Any] | None = None,
    generation_config: Any = None,
) -> LLMTextResult:
    return llm_router.generate_text(
        LLMTextRequest(
            task=task,
            prompt=prompt,
            system_prompt=system_prompt,
            metadata=dict(metadata or {}),
            generation_config=generation_config,
        )
    )
