Coverage for src / local_deep_research / advanced_search_system / findings / base_findings.py: 79%

19 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2026-01-11 00:51 +0000

1""" 

2Base class for all findings repositories. 

3Defines the common interface and shared functionality for different findings management approaches. 

4""" 

5 

6from abc import ABC, abstractmethod 

7from typing import Dict, List 

8 

9from langchain_core.language_models import BaseLLM 

10 

11 

12class BaseFindingsRepository(ABC): 

13 """Abstract base class for all findings repositories.""" 

14 

15 def __init__(self, model: BaseLLM): 

16 """ 

17 Initialize the findings repository. 

18 

19 Args: 

20 model: The language model to use for findings operations 

21 """ 

22 self.model = model 

23 self.findings: Dict[str, List[str]] = {} 

24 

25 @abstractmethod 

26 def add_finding(self, query: str, finding: Dict | str) -> None: 

27 """ 

28 Add a finding to the repository. 

29 

30 Args: 

31 query: The query associated with the finding 

32 finding: The finding to add 

33 """ 

34 pass 

35 

36 @abstractmethod 

37 def get_findings(self, query: str) -> List[str]: 

38 """ 

39 Get findings for a query. 

40 

41 Args: 

42 query: The query to get findings for 

43 

44 Returns: 

45 List[str]: List of findings for the query 

46 """ 

47 pass 

48 

49 @abstractmethod 

50 def clear_findings(self, query: str) -> None: 

51 """ 

52 Clear findings for a query. 

53 

54 Args: 

55 query: The query to clear findings for 

56 """ 

57 pass 

58 

59 @abstractmethod 

60 def synthesize_findings( 

61 self, 

62 query: str, 

63 sub_queries: List[str], 

64 findings: List[str], 

65 accumulated_knowledge: str, 

66 ) -> str: 

67 """ 

68 Synthesize findings from sub-queries into a final answer. 

69 

70 Args: 

71 query: The original query 

72 sub_queries: List of sub-queries 

73 findings: List of findings for each sub-query 

74 accumulated_knowledge: Accumulated knowledge from previous findings 

75 Returns: 

76 str: Synthesized final answer 

77 """ 

78 pass