Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Pydantic Schema Usage #2745

Open
eyurtsev opened this issue Dec 12, 2024 · 1 comment
Open

Document Pydantic Schema Usage #2745

eyurtsev opened this issue Dec 12, 2024 · 1 comment
Assignees
Labels
maintainer Issue created by library maintainer

Comments

@eyurtsev
Copy link
Contributor

Issue with current documentation:

from langgraph.graph import StateGraph
from langgraph.constants import START
from pydantic import BaseModel

class Foo(BaseModel):
    x: int
    y: str

def node(state: Foo):
    """This parent node will invoke the subgraph."""
    return state

builder = StateGraph(Foo)
builder.add_node("node", node)
builder.add_edge(START, "node")
graph = builder.compile()
result = graph.invoke(Foo(x=3, y="hello"))
Foo(**result)

Idea or request for content:

Figure out where to document current behavior + run time coercion

@eyurtsev eyurtsev self-assigned this Dec 12, 2024
@hinthornw
Copy link
Contributor

Another point here is that if you use BaseMessage without the add_messages reducer (or an equivalent), messages you send over the wire will be deserialized as just that.
instead should use AnyMessage.

@vbarda vbarda added the maintainer Issue created by library maintainer label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer Issue created by library maintainer
Projects
None yet
Development

No branches or pull requests

3 participants