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

14 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-02-25 01:07 +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 

7 

8 

9class BaseQuestionGenerator(ABC): 

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

11 

12 def __init__(self, model): 

13 """ 

14 Initialize the question generator. 

15 

16 Args: 

17 model: The language model to use for question generation 

18 """ 

19 self.model = model 

20 

21 @abstractmethod 

22 def generate_questions( 

23 self, 

24 current_knowledge: str, 

25 query: str, 

26 questions_per_iteration: int, 

27 questions_by_iteration: dict[int, list[str]], 

28 ) -> list[str]: 

29 """ 

30 Generate questions based on the current state of research. 

31 

32 Args: 

33 current_knowledge: The accumulated knowledge so far 

34 query: The original research query 

35 questions_per_iteration: Number of questions to generate per iteration 

36 questions_by_iteration: Questions generated in previous iterations 

37 

38 Returns: 

39 list[str]: Generated questions 

40 """ 

41 pass 

42 

43 def _format_previous_questions( 

44 self, questions_by_iteration: dict[int, list[str]] 

45 ) -> str: 

46 """ 

47 Format previous questions for context. 

48 

49 Args: 

50 questions_by_iteration: Questions generated in previous iterations 

51 

52 Returns: 

53 str: Formatted string of previous questions 

54 """ 

55 formatted = [] 

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

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

58 for q in questions: 

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

60 return "\n".join(formatted)