"""LLM summarizer biased toward a focus query."""

from langchain_core.language_models.chat_models import BaseChatModel

from .base import BaseSummarizer


class FocusedSummarizer(BaseSummarizer):
    """Produces a summary biased toward aspects relevant to a focus query."""

    def __init__(
        self,
        model: BaseChatModel,
        focus_query: str,
        max_sentences: int = 3,
        max_chars: int = 300,
    ):
        super().__init__(
            model, max_sentences=max_sentences, max_chars=max_chars
        )
        self.focus_query = focus_query

    def _build_prompt(self, content: str) -> str:
        return (
            f"Summarize the following text in {self.max_sentences} sentence(s), "
            f"focusing on aspects relevant to: {self.focus_query!r}. "
            "Return ONLY the summary text, no preamble or explanation.\n\n"
            f"Text:\n{content}"
        )
