LangGraph
Code Examples
MessagesState vs GraphState
Since having a list of messages in your state is a common requirement, a prebuilt state called MessagesState
is available to simplify message handling. MessagesState
is defined with a single messages
key, which is a list of AnyMessage
objects, and it uses the add_messages
reducer for state updates.
Using MessagesState
:
The StateGraph
equivalent of MessagesState
is as follows:
Last updated