Skip to content

Commit 7743525

Browse files
committed
Refactor context retrieval to include advanced model for improved query handling
1 parent 88416c4 commit 7743525

8 files changed

Lines changed: 21 additions & 11 deletions

prometheus/lang_graph/nodes/context_retrieval_subgraph_node.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
class ContextRetrievalSubgraphNode:
1414
def __init__(
1515
self,
16-
model: BaseChatModel,
16+
base_model: BaseChatModel,
17+
advanced_model: BaseChatModel,
1718
kg: KnowledgeGraph,
1819
local_path: str,
1920
query_key_name: str,
@@ -22,7 +23,8 @@ def __init__(
2223
):
2324
self._logger = logging.getLogger(f"thread-{threading.get_ident()}.{__name__}")
2425
self.context_retrieval_subgraph = ContextRetrievalSubgraph(
25-
model=model,
26+
base_model=base_model,
27+
advanced_model=advanced_model,
2628
kg=kg,
2729
local_path=local_path,
2830
repository_id=repository_id,

prometheus/lang_graph/subgraphs/bug_get_regression_tests_subgraph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
# Step 2: Retrieve relevant code/documentation context from the knowledge graph
5656
context_retrieval_subgraph_node = ContextRetrievalSubgraphNode(
5757
base_model,
58+
advanced_model,
5859
kg,
5960
git_repo.playground_path,
6061
"select_regression_query",

prometheus/lang_graph/subgraphs/bug_reproduction_subgraph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(
6363
# Step 2: Retrieve relevant code/documentation context from the knowledge graph
6464
context_retrieval_subgraph_node = ContextRetrievalSubgraphNode(
6565
base_model,
66+
advanced_model,
6667
kg,
6768
git_repo.playground_path,
6869
"bug_reproducing_query",

prometheus/lang_graph/subgraphs/context_retrieval_subgraph.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class ContextRetrievalSubgraph:
6868

6969
def __init__(
7070
self,
71-
model: BaseChatModel,
71+
base_model: BaseChatModel,
72+
advanced_model: BaseChatModel,
7273
kg: KnowledgeGraph,
7374
local_path: str,
7475
repository_id: int,
@@ -77,19 +78,20 @@ def __init__(
7778
Initializes the context retrieval subgraph.
7879
7980
Args:
80-
model (BaseChatModel): The LLM used for context selection and refinement.
81+
base_model (BaseChatModel): The LLM used for context selection and refinement.
82+
advanced_model (BaseChatModel): The LLM used for advanced tasks like query refinement and context extraction.
8183
kg (KnowledgeGraph): Knowledge graph instance
8284
local_path (str): Local path to the codebase for context extraction.
8385
repository_id (int): Repository ID for memory storage
8486
"""
8587
# Step 1: Refine query into structured format
86-
context_refine_node = ContextRefineNode(model=model, kg=kg)
88+
context_refine_node = ContextRefineNode(model=advanced_model, kg=kg)
8789

8890
# Step 2: Retrieve contexts from semantic memory (Athena)
8991
memory_retrieval_node = MemoryRetrievalNode(repository_id=repository_id)
9092

9193
# Step 3: Extract relevant contexts from explored_context
92-
context_extraction_node = ContextExtractionNode(model=model, root_path=local_path)
94+
context_extraction_node = ContextExtractionNode(model=advanced_model, root_path=local_path)
9395

9496
# Step 4: Store new contexts to memory
9597
memory_storage_node = MemoryStorageNode(repository_id=repository_id)
@@ -101,7 +103,7 @@ def __init__(
101103
add_context_refined_query_message_node = AddContextRefinedQueryMessageNode()
102104

103105
# Step 7: Query knowledge graph (Neo4j) using LLM tools
104-
context_provider_node = ContextProviderNode(model=model, kg=kg, local_path=local_path)
106+
context_provider_node = ContextProviderNode(model=base_model, kg=kg, local_path=local_path)
105107
context_provider_tools = ToolNode(
106108
tools=context_provider_node.tools,
107109
name="context_provider_tools",

prometheus/lang_graph/subgraphs/issue_classification_subgraph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def __init__(
2222
):
2323
issue_classification_context_message_node = IssueClassificationContextMessageNode()
2424
context_retrieval_subgraph_node = ContextRetrievalSubgraphNode(
25-
model=model,
25+
base_model=model,
26+
advanced_model=model,
2627
kg=kg,
2728
local_path=local_path,
2829
query_key_name="issue_classification_query",

prometheus/lang_graph/subgraphs/issue_not_verified_bug_subgraph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def __init__(
3737
):
3838
issue_bug_context_message_node = IssueBugContextMessageNode()
3939
context_retrieval_subgraph_node = ContextRetrievalSubgraphNode(
40-
model=base_model,
40+
base_model=base_model,
41+
advanced_model=advanced_model,
4142
kg=kg,
4243
local_path=git_repo.playground_path,
4344
query_key_name="bug_fix_query",

prometheus/lang_graph/subgraphs/issue_question_subgraph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def __init__(
3737
# Step 1: Retrieve relevant context based on the issue details
3838
issue_question_context_message_node = IssueQuestionContextMessageNode()
3939
context_retrieval_subgraph_node = ContextRetrievalSubgraphNode(
40-
model=base_model,
40+
base_model=base_model,
41+
advanced_model=advanced_model,
4142
kg=kg,
4243
local_path=git_repo.playground_path,
4344
query_key_name="question_query",

prometheus/lang_graph/subgraphs/issue_verified_bug_subgraph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def __init__(
7373
# Phase 1: Retrieve context related to the bug
7474
issue_bug_context_message_node = IssueBugContextMessageNode()
7575
context_retrieval_subgraph_node = ContextRetrievalSubgraphNode(
76-
model=base_model,
76+
base_model=base_model,
77+
advanced_model=advanced_model,
7778
kg=kg,
7879
local_path=git_repo.playground_path,
7980
query_key_name="bug_fix_query",

0 commit comments

Comments
 (0)