Coverage for src / local_deep_research / advanced_search_system / questions / followup / base_followup_question.py: 64%
14 statements
« prev ^ index » next coverage.py v7.12.0, created at 2026-01-11 00:51 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2026-01-11 00:51 +0000
1"""
2Base class for follow-up question generators.
4This extends the standard question generator interface to handle
5follow-up research that includes previous research context.
6"""
8from abc import abstractmethod
9from typing import Dict, List
10from ..base_question import BaseQuestionGenerator
13class BaseFollowUpQuestionGenerator(BaseQuestionGenerator):
14 """
15 Abstract base class for follow-up question generators.
17 These generators create contextualized queries that incorporate
18 previous research findings and context.
19 """
21 def __init__(self, model):
22 """
23 Initialize the follow-up question generator.
25 Args:
26 model: The language model to use for question generation
27 """
28 super().__init__(model)
29 self.follow_up_context = {}
31 def set_follow_up_context(self, context: Dict):
32 """
33 Set the follow-up research context.
35 Args:
36 context: Dictionary containing:
37 - past_findings: Previous research findings
38 - original_query: The original research query
39 - follow_up_query: The follow-up question from user
40 - past_sources: Sources from previous research
41 - key_entities: Key entities identified
42 """
43 self.follow_up_context = context
45 @abstractmethod
46 def generate_contextualized_query(
47 self,
48 follow_up_query: str,
49 original_query: str,
50 past_findings: str,
51 **kwargs,
52 ) -> str:
53 """
54 Generate a contextualized query for follow-up research.
56 Args:
57 follow_up_query: The user's follow-up question
58 original_query: The original research query
59 past_findings: The findings from previous research
60 **kwargs: Additional context parameters
62 Returns:
63 str: A contextualized query that includes previous context
64 """
65 pass
67 def generate_questions(
68 self,
69 current_knowledge: str,
70 query: str,
71 questions_per_iteration: int,
72 questions_by_iteration: Dict[int, List[str]],
73 ) -> List[str]:
74 """
75 Generate questions for follow-up research.
77 For follow-up research, we typically return a single contextualized
78 query rather than multiple questions, as the context is already rich.
80 Args:
81 current_knowledge: The accumulated knowledge so far
82 query: The research query (already contextualized)
83 questions_per_iteration: Number of questions to generate
84 questions_by_iteration: Previous questions
86 Returns:
87 List[str]: List containing the contextualized query
88 """
89 # For follow-up research, the query is already contextualized
90 # Just return it as a single-item list
91 return [query]