Coverage for src / local_deep_research / advanced_search_system / questions / followup / simple_followup_question.py: 57%
7 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"""
2Simple concatenation-based follow-up question generator.
4This implementation preserves the current behavior of concatenating
5the previous research context with the follow-up query without using
6an LLM to reformulate.
7"""
9from loguru import logger
10from .base_followup_question import BaseFollowUpQuestionGenerator
13class SimpleFollowUpQuestionGenerator(BaseFollowUpQuestionGenerator):
14 """
15 Simple follow-up question generator that concatenates context.
17 This generator creates a contextualized query by directly concatenating
18 the previous research findings with the follow-up question, without
19 any LLM-based reformulation. This ensures the follow-up query is
20 understood in the context of previous research.
21 """
23 def generate_contextualized_query(
24 self,
25 follow_up_query: str,
26 original_query: str,
27 past_findings: str,
28 **kwargs,
29 ) -> str:
30 """
31 Generate a contextualized query by simple concatenation.
33 This method preserves the exact user query while providing full
34 context from previous research. This ensures queries like
35 "provide data in a table" are understood as referring to the
36 previous findings, not as new searches.
38 Args:
39 follow_up_query: The user's follow-up question
40 original_query: The original research query
41 past_findings: The findings from previous research
42 **kwargs: Additional context parameters (unused)
44 Returns:
45 str: A contextualized query with previous research embedded
46 """
47 # Simply concatenate the context with the query - no LLM interpretation needed
48 # Highlight importance at top, actual request at bottom
49 contextualized = f"""IMPORTANT: This is a follow-up request. Focus on addressing the specific user request at the bottom of this prompt using the previous research context provided below.
51Previous research query: {original_query}
53Previous findings:
54{past_findings}
56---
57USER'S FOLLOW-UP REQUEST: {follow_up_query}
58Please address this specific request using the context and findings above.
59---"""
61 logger.info(
62 f"Created contextualized query with {len(past_findings)} chars of context"
63 )
65 return contextualized