Spaces:
Runtime error
Runtime error
File size: 854 Bytes
925212b 796674b 925212b 796674b 925212b 796674b |
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 30 31 32 33 34 |
from langgraph.graph import Graph
from typing import TypedDict
# Define the state type
class State(TypedDict):
messages: list[str]
current_step: str
# Create nodes (functions that represent different states)
def collect_info(state: State) -> State:
return {
**state,
"messages": state["messages"] + ["Information collected"],
"current_step": "process"
}
def process_info(state: State) -> State:
return {
**state,
"messages": state["messages"] + ["Information processed"],
"current_step": "end"
}
# Create the graph
workflow = Graph()
# Add nodes and edges
workflow.add_node("collect", collect_info)
workflow.add_node("process", process_info)
workflow.add_edge("collect", "process")
# Set the entry point and compile
workflow.set_entry_point("collect")
app = workflow.compile() |