Spaces:
Sleeping
Sleeping
File size: 737 Bytes
f8734b3 bcfaa84 f8734b3 bcfaa84 f8734b3 bcfaa84 f8734b3 bcfaa84 f8734b3 bcfaa84 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | from langgraph.graph import StateGraph
from llm_node import llm_node
from formatter_node import formatter_node
class AgentState(dict):
pass
def build_graph():
graph = StateGraph(AgentState)
def llm_step(state):
question = state["question"]
llm_output = llm_node(question)
state["llm_output"] = llm_output
return state
def formatter_step(state):
final_answer = formatter_node(state["llm_output"])
state["final_answer"] = final_answer
return state
graph.add_node("llm", llm_step)
graph.add_node("formatter", formatter_step)
graph.set_entry_point("llm")
graph.add_edge("llm", "formatter")
graph.set_finish_point("formatter")
return graph
|