Created
April 26, 2025 06:31
-
-
Save ashen007/8efaa70de78538d6ea59eb14f8bb76bc to your computer and use it in GitHub Desktop.
Revisions
-
ashen007 created this gist
Apr 26, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ from langgraph.graph import StateGraph, START, END from langgraph.graph.graph import CompiledGraph from states import State from tools.database_tools import db_query_tool from tools.tool_nodes import query_gen_node, should_continue, final_answer_node from tools.error_handling import create_tool_node_with_fallback def run() -> CompiledGraph: workflow = StateGraph(State) workflow.add_node("query_gen", query_gen_node) workflow.add_node("execute_query", create_tool_node_with_fallback([db_query_tool])) workflow.add_node('final_answer', final_answer_node) workflow.add_edge(START, "query_gen") workflow.add_edge("query_gen", "execute_query") workflow.add_conditional_edges("execute_query", should_continue) workflow.add_edge("final_answer", END) # Compile the workflow into a runnable app = workflow.compile() return app