Coverage for src / local_deep_research / advanced_search_system / questions / base_question.py: 42%

15 statements  

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

1""" 

2Base class for all question generators. 

3Defines the common interface and shared functionality for different question generation approaches. 

4""" 

5 

6from abc import ABC, abstractmethod 

7from typing import Dict, List 

8 

9 

10class BaseQuestionGenerator(ABC): 

11 """Abstract base class for all question generators.""" 

12 

13 def __init__(self, model): 

14 """ 

15 Initialize the question generator. 

16 

17 Args: 

18 model: The language model to use for question generation 

19 """ 

20 self.model = model 

21 

22 @abstractmethod 

23 def generate_questions( 

24 self, 

25 current_knowledge: str, 

26 query: str, 

27 questions_per_iteration: int, 

28 questions_by_iteration: Dict[int, List[str]], 

29 ) -> List[str]: 

30 """ 

31 Generate questions based on the current state of research. 

32 

33 Args: 

34 current_knowledge: The accumulated knowledge so far 

35 query: The original research query 

36 questions_per_iteration: Number of questions to generate per iteration 

37 questions_by_iteration: Questions generated in previous iterations 

38 

39 Returns: 

40 List[str]: Generated questions 

41 """ 

42 pass 

43 

44 def _format_previous_questions( 

45 self, questions_by_iteration: Dict[int, List[str]] 

46 ) -> str: 

47 """ 

48 Format previous questions for context. 

49 

50 Args: 

51 questions_by_iteration: Questions generated in previous iterations 

52 

53 Returns: 

54 str: Formatted string of previous questions 

55 """ 

56 formatted = [] 

57 for iteration, questions in questions_by_iteration.items(): 

58 formatted.append(f"Iteration {iteration}:") 

59 for q in questions: 

60 formatted.append(f"- {q}") 

61 return "\n".join(formatted)