File size: 663 Bytes
b02630d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Summarization helper using the main LLM."""

from config.config import Config


class SummarizerTool:
    """Summarizes long texts using the LLM."""

    def __init__(self) -> None:
        self.llm = Config.get_llm()

    def summarize(self, text: str, max_words: int = 300) -> str:
        """
        Summarize the provided text.

        Args:
            text: Input text.
            max_words: Target summary length.

        Returns:
            Summary string.
        """
        prompt = (
            f"Summarize the following text in about {max_words} words:\n\n{text}"
        )
        resp = self.llm.invoke(prompt)
        return resp.content