Spaces:
Sleeping
Sleeping
Update graph_builder.py
Browse files- graph_builder.py +6 -6
graph_builder.py
CHANGED
|
@@ -1,7 +1,4 @@
|
|
| 1 |
from langgraph.graph import StateGraph
|
| 2 |
-
from langchain_core.runnables import RunnableConfig
|
| 3 |
-
from llm_node import llm_node
|
| 4 |
-
from formatter_node import formatter_node
|
| 5 |
|
| 6 |
class AgentState(dict):
|
| 7 |
"""
|
|
@@ -17,10 +14,13 @@ class AgentState(dict):
|
|
| 17 |
raise ValueError("AgentState requires a 'question' key at init")
|
| 18 |
self.update(initial_data)
|
| 19 |
|
|
|
|
|
|
|
|
|
|
| 20 |
def build_graph():
|
| 21 |
graph = StateGraph(AgentState)
|
| 22 |
|
| 23 |
-
def llm_step(state
|
| 24 |
question = state.get("question")
|
| 25 |
if not question:
|
| 26 |
raise ValueError("Missing 'question' in state")
|
|
@@ -28,7 +28,7 @@ def build_graph():
|
|
| 28 |
state["llm_output"] = llm_output
|
| 29 |
return state
|
| 30 |
|
| 31 |
-
def formatter_step(state
|
| 32 |
llm_output = state.get("llm_output")
|
| 33 |
if not llm_output:
|
| 34 |
raise ValueError("Missing 'llm_output' in state")
|
|
@@ -38,7 +38,7 @@ def build_graph():
|
|
| 38 |
|
| 39 |
graph.add_node("llm", llm_step)
|
| 40 |
graph.add_node("formatter", formatter_step)
|
| 41 |
-
graph.set_entry_point("llm"
|
| 42 |
graph.add_edge("llm", "formatter")
|
| 43 |
graph.set_finish_point("formatter")
|
| 44 |
|
|
|
|
| 1 |
from langgraph.graph import StateGraph
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
class AgentState(dict):
|
| 4 |
"""
|
|
|
|
| 14 |
raise ValueError("AgentState requires a 'question' key at init")
|
| 15 |
self.update(initial_data)
|
| 16 |
|
| 17 |
+
from llm_node import llm_node
|
| 18 |
+
from formatter_node import formatter_node
|
| 19 |
+
|
| 20 |
def build_graph():
|
| 21 |
graph = StateGraph(AgentState)
|
| 22 |
|
| 23 |
+
def llm_step(state):
|
| 24 |
question = state.get("question")
|
| 25 |
if not question:
|
| 26 |
raise ValueError("Missing 'question' in state")
|
|
|
|
| 28 |
state["llm_output"] = llm_output
|
| 29 |
return state
|
| 30 |
|
| 31 |
+
def formatter_step(state):
|
| 32 |
llm_output = state.get("llm_output")
|
| 33 |
if not llm_output:
|
| 34 |
raise ValueError("Missing 'llm_output' in state")
|
|
|
|
| 38 |
|
| 39 |
graph.add_node("llm", llm_step)
|
| 40 |
graph.add_node("formatter", formatter_step)
|
| 41 |
+
graph.set_entry_point("llm") # ✅ no input_key
|
| 42 |
graph.add_edge("llm", "formatter")
|
| 43 |
graph.set_finish_point("formatter")
|
| 44 |
|