mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
2.3 KiB
2.3 KiB
In [12]:
from langgraph.graph import StateGraph, START, END
from typing import TypedDict
class InputState(TypedDict):
question: str
class OutputState(TypedDict):
answer: str
def answer_node(state: InputState):
return {"answer": "bye"}
graph = StateGraph(input=InputState, output=OutputState)
graph.add_node(answer_node)
graph.add_edge(START, "answer_node")
graph.add_edge("answer_node", END)
graph = graph.compile()
graph.invoke({"question": "hi"})Out [12]:
{'answer': 'bye'}