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

Issue with Pydantic #1603

Open
hwchase17 opened this issue Aug 5, 2024 · 3 comments
Open

Issue with Pydantic #1603

hwchase17 opened this issue Aug 5, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@hwchase17
Copy link
Contributor

1/ a graph state key is a Pydantic model
class Analyst(BaseModel):
description: str = Field(
2/ i edit it in Studio
3/ edited state is no long a Pydantic model (converted to dict after edit in Studio, IIUC)
4/ anything in code that assumes Pydantic model will then break w/ the edited state
e.g., accessing one attribute -
analyst.description
error -
AttributeError: 'dict' object has no attribute 'description'

@hwchase17 hwchase17 added the bug Something isn't working label Aug 5, 2024
@dqbd dqbd transferred this issue from langchain-ai/langgraph-studio Sep 4, 2024
@dqbd
Copy link
Contributor

dqbd commented Sep 4, 2024

@nfcampos Seems like a LangGraph issue? Don't think Studio does anything else here differently?

@oleksandr-lytvynenko
Copy link

oleksandr-lytvynenko commented Sep 13, 2024

got similar issue

Here's my agent state class
Screenshot 2024-09-13 at 15 42 48

Did the setup right as described at https://langchain-ai.github.io/langgraph/how-tos/state-model/#how-to-use-pydantic-model-as-state

Here's the error I'm getting
Screenshot 2024-09-13 at 15 40 50

When launching w/o LangGraph Studio, it works OK


The issue is very likely roots in using Pydantic for agent state.
I checked it by returning to using TypedDict for agent state and this worked in Langgrapg Studio

@khyaalnix
Copy link

Is there any update on using pydantic model for state ? Facing a similar issue as @oleksandr-lytvynenko.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants