Coverage for src/local_deep_research/advanced_search_system/summarization/focused.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-03 23:15 +0000

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

2 

3from langchain_core.language_models.chat_models import BaseChatModel 

4 

5from .base import BaseSummarizer 

6 

7 

8class FocusedSummarizer(BaseSummarizer): 

9 """Produces a summary biased toward aspects relevant to a focus query.""" 

10 

11 def __init__( 

12 self, 

13 model: BaseChatModel, 

14 focus_query: str, 

15 max_sentences: int = 3, 

16 max_chars: int = 300, 

17 ): 

18 super().__init__( 

19 model, max_sentences=max_sentences, max_chars=max_chars 

20 ) 

21 self.focus_query = focus_query 

22 

23 def _build_prompt(self, content: str) -> str: 

24 return ( 

25 f"Summarize the following text in {self.max_sentences} sentence(s), " 

26 f"focusing on aspects relevant to: {self.focus_query!r}. " 

27 "Return ONLY the summary text, no preamble or explanation.\n\n" 

28 f"Text:\n{content}" 

29 )