jstoppa's picture
Update app.py
796674b verified
raw
history blame
854 Bytes
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()