Spaces:
Sleeping
Sleeping
| 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 | |