File size: 620 Bytes
0b19c40
 
 
 
 
 
a10e2f7
0b19c40
 
 
a10e2f7
1
2
3
4
5
6
7
8
9
10
11
12
from typing import Annotated, Literal, Optional
from typing_extensions import TypedDict
from langgraph.graph.message import add_messages
from typing import TypedDict, Annotated, List
from langchain_core.messages import HumanMessage, AIMessage

class State(TypedDict): #State is a class that inherits from TypedDict, State will act like a dictionary but with fixed keys and expected data types
    """
    Represents the structure of the state used in the graph.
    """
    messages: Annotated[list, add_messages] # messages is a key inside State dictionary and Annotated → A way to add extra metadata to a type hint.