more renaming and consolidation

This commit is contained in:
joachim-danswer 2025-01-30 15:09:53 -08:00 committed by Evan Lohn
parent 2517aa39b2
commit b0c3098693
6 changed files with 40 additions and 83 deletions

View File

@ -32,7 +32,7 @@ def parallelize_initial_sub_question_answering(
return [
Send(
"answer_query_subgraph",
"answer_sub_question_subgraph",
AnswerQuestionInput(
question=question,
question_id=make_question_id(0, question_nr + 1),

View File

@ -8,8 +8,8 @@ from onyx.agents.agent_search.deep_search_a.initial.consolidate_sub_answers.edge
from onyx.agents.agent_search.deep_search_a.initial.consolidate_sub_answers.nodes.decompose_orig_question import (
decompose_orig_question,
)
from onyx.agents.agent_search.deep_search_a.initial.consolidate_sub_answers.nodes.ingest_initial_sub_answers import (
ingest_initial_sub_answers,
from onyx.agents.agent_search.deep_search_a.initial.consolidate_sub_answers.nodes.format_initial_sub_answers import (
format_initial_sub_answers,
)
from onyx.agents.agent_search.deep_search_a.initial.consolidate_sub_answers.states import (
SQInput,
@ -37,15 +37,15 @@ def consolidate_sub_answers_graph_builder() -> StateGraph:
node="decompose_orig_question",
action=decompose_orig_question,
)
answer_query_subgraph = answer_query_graph_builder().compile()
answer_sub_question_subgraph = answer_query_graph_builder().compile()
graph.add_node(
node="answer_query_subgraph",
action=answer_query_subgraph,
node="answer_sub_question_subgraph",
action=answer_sub_question_subgraph,
)
graph.add_node(
node="ingest_initial_sub_question_answers",
action=ingest_initial_sub_answers,
node="format_initial_sub_question_answers",
action=format_initial_sub_answers,
)
### Add edges ###
@ -75,15 +75,15 @@ def consolidate_sub_answers_graph_builder() -> StateGraph:
graph.add_conditional_edges(
source="decompose_orig_question",
path=parallelize_initial_sub_question_answering,
path_map=["answer_query_subgraph"],
path_map=["answer_sub_question_subgraph"],
)
graph.add_edge(
start_key="answer_query_subgraph",
end_key="ingest_initial_sub_question_answers",
start_key="answer_sub_question_subgraph",
end_key="format_initial_sub_question_answers",
)
graph.add_edge(
start_key="ingest_initial_sub_question_answers",
start_key="format_initial_sub_question_answers",
end_key=END,
)

View File

@ -12,7 +12,7 @@ from onyx.agents.agent_search.shared_graph_utils.operators import (
)
def ingest_initial_sub_answers(
def format_initial_sub_answers(
state: AnswerQuestionOutput,
) -> DecompAnswersUpdate:
now_start = datetime.now()

View File

@ -5,9 +5,6 @@ from langgraph.graph import StateGraph
from onyx.agents.agent_search.deep_search_a.initial.consolidate_sub_answers.graph_builder import (
consolidate_sub_answers_graph_builder,
)
from onyx.agents.agent_search.deep_search_a.initial.generate_initial_answer.nodes.consolidate_retrieved_documents import (
consolidate_retrieved_documents,
)
from onyx.agents.agent_search.deep_search_a.initial.generate_initial_answer.nodes.generate_initial_answer import (
generate_initial_answer,
)
@ -21,7 +18,7 @@ from onyx.agents.agent_search.deep_search_a.initial.generate_initial_answer.stat
SearchSQState,
)
from onyx.agents.agent_search.deep_search_a.initial.retrieve_orig_question_docs.graph_builder import (
base_raw_search_graph_builder,
retrieve_orig_question_docs_graph_builder,
)
from onyx.utils.logger import setup_logger
@ -34,34 +31,23 @@ def generate_initial_answer_graph_builder(test_mode: bool = False) -> StateGraph
input=SearchSQInput,
)
# graph.add_node(
# node="initial_sub_question_creation",
# action=initial_sub_question_creation,
# )
consolidate_sub_answers = consolidate_sub_answers_graph_builder().compile()
graph.add_node(
node="consolidate_sub_answers",
node="consolidate_sub_answers_subgraph",
action=consolidate_sub_answers,
)
# answer_query_subgraph = answer_query_graph_builder().compile()
retrieve_orig_question_docs = retrieve_orig_question_docs_graph_builder().compile()
graph.add_node(
node="retrieve_orig_question_docs_subgraph",
action=retrieve_orig_question_docs,
)
# graph.add_node(
# node="answer_query_subgraph",
# action=answer_query_subgraph,
# node="retrieval_consolidation",
# action=consolidate_retrieved_documents,
# )
base_raw_search_subgraph = base_raw_search_graph_builder().compile()
graph.add_node(
node="base_raw_search_subgraph",
action=base_raw_search_subgraph,
)
graph.add_node(
node="retrieval_consolidation",
action=consolidate_retrieved_documents,
)
graph.add_node(
node="generate_initial_answer",
action=generate_initial_answer,
@ -74,48 +60,29 @@ def generate_initial_answer_graph_builder(test_mode: bool = False) -> StateGraph
### Add edges ###
# raph.add_edge(start_key=START, end_key="base_raw_search_subgraph")
graph.add_edge(
start_key=START,
end_key="retrieve_orig_question_docs_subgraph",
)
graph.add_edge(
start_key=START,
end_key="base_raw_search_subgraph",
)
# graph.add_edge(
# start_key="agent_search_start",
# end_key="entity_term_extraction_llm",
# )
graph.add_edge(
start_key=START,
end_key="consolidate_sub_answers",
end_key="consolidate_sub_answers_subgraph",
)
graph.add_edge(
start_key=["base_raw_search_subgraph", "consolidate_sub_answers"],
end_key="retrieval_consolidation",
)
graph.add_edge(
start_key="retrieval_consolidation",
start_key=[
"retrieve_orig_question_docs_subgraph",
"consolidate_sub_answers_subgraph",
],
end_key="generate_initial_answer",
)
# graph.add_edge(
# start_key="LLM",
# end_key=END,
# start_key="retrieval_consolidation",
# end_key="generate_initial_answer",
# )
# graph.add_edge(
# start_key=START,
# end_key="initial_sub_question_creation",
# )
graph.add_edge(
start_key="retrieval_consolidation",
end_key="generate_initial_answer",
)
graph.add_edge(
start_key="generate_initial_answer",
end_key="validate_initial_answer",
@ -126,14 +93,4 @@ def generate_initial_answer_graph_builder(test_mode: bool = False) -> StateGraph
end_key=END,
)
# graph.add_edge(
# start_key="generate_refined_answer",
# end_key="check_refined_answer",
# )
# graph.add_edge(
# start_key="check_refined_answer",
# end_key=END,
# )
return graph

View File

@ -22,7 +22,7 @@ from onyx.agents.agent_search.deep_search_a.shared.expanded_retrieval.graph_buil
)
def base_raw_search_graph_builder() -> StateGraph:
def retrieve_orig_question_docs_graph_builder() -> StateGraph:
graph = StateGraph(
state_schema=BaseRawSearchState,
input=BaseRawSearchInput,

View File

@ -106,10 +106,10 @@ def main_graph_builder(test_mode: bool = False) -> StateGraph:
# action=initial_sub_question_creation,
# )
generate_initial_answer_graph = generate_initial_answer_graph_builder().compile()
generate_initial_answer_subgraph = generate_initial_answer_graph_builder().compile()
graph.add_node(
node="generate_initial_answer_graph",
action=generate_initial_answer_graph,
node="generate_initial_answer_subgraph",
action=generate_initial_answer_subgraph,
)
# answer_query_subgraph = answer_query_graph_builder().compile()
@ -239,7 +239,7 @@ def main_graph_builder(test_mode: bool = False) -> StateGraph:
graph.add_edge(
start_key="agent_search_start",
end_key="generate_initial_answer_graph",
end_key="generate_initial_answer_subgraph",
)
# graph.add_edge(
# start_key="agent_search_start",
@ -316,7 +316,7 @@ def main_graph_builder(test_mode: bool = False) -> StateGraph:
# )
graph.add_edge(
start_key=["generate_initial_answer_graph", "entity_term_extraction_llm"],
start_key=["generate_initial_answer_subgraph", "entity_term_extraction_llm"],
end_key="refined_answer_decision",
)