Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

915 B
Raw Blame
"""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}"
        )