-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedmaintainerIssue created by library maintainerIssue created by library maintainer
Description
Privileged issue
- I am a LangChain maintainer, or was asked directly by a LangChain maintainer to create an issue here.
Issue Content
MRE
from pydantic import BaseModel, Field
from langgraph.graph import StateGraph
class Foo(BaseModel):
foo: str = Field(alias='bar')
# Define a new graph
graph_builder = StateGraph(
Foo
)
def node(foo: Foo):
print(foo)
return None
# Add the node to the graph
graph_builder.add_node("node", node)
# Set the entrypoint as `call_model`
graph_builder.add_edge("__start__", "node")
# Compile the workflow into an executable graph
graph = graph_builder.compile()
graph.invoke({'bar': 'hello'})
Expected behavior
The alias should be respected and the field foo
should be only updateable by alias.
Observed behavior
Validation error.
Context
- Mostly a problem for IO boundaries (since that's where I actually use pydantic models)
- alias is needed in some cases to avoid name collisions (e.g.,
schema
field is already taken by pydantic)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedmaintainerIssue created by library maintainerIssue created by library maintainer