Spaces:
Sleeping
Sleeping
Download graph_builder.py from Umer797/Final_Assignment_Template: direct link, hf CLI and curl.
- Browser
- Download file 671 Bytes
-
https://huggingface.co/spaces/Umer797/Final_Assignment_Template/resolve/refs%2Fpr%2F1/graph_builder.py
- Command line
-
hf download hf://spaces/Umer797/Final_Assignment_Template@refs/pr/1/graph_builder.py
-
curl -L -o graph_builder.py https://huggingface.co/spaces/Umer797/Final_Assignment_Template/resolve/refs%2Fpr%2F1/graph_builder.py
671 Bytes
| from langgraph.graph import Graph | |
| from llm_node import llm_node | |
| from formatter_node import formatter_node | |
| def build_graph(): | |
| graph = Graph() | |
| def llm_step(state): | |
| question = state["question"] | |
| result = llm_node().run(question) | |
| state["llm_output"] = result | |
| return state | |
| def formatter_step(state): | |
| cleaned = formatter_node(state["llm_output"]) | |
| state["final_answer"] = cleaned | |
| 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 | |