-
Notifications
You must be signed in to change notification settings - Fork 214
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
Value not declarable with JSON Schema (Pydantic V2) #690
Comments
LangChain does not currently support pydantic 2 models. If you're using pydantic 2, you need to use the pydantic.v1 namespace Do this in your code; from pydantic.v1 import BaseModel |
Is there a tracking issue for when LangServe will support Pydantic 2? Or is there a way to use the I'm asking because I have found that the most recent release of LangChain no longer support Pydantic V1 at all due to this commit which introduced the following change to the pydantic = [
{ version = ">=1,<3", python = "<3.12.4" },
{ version = "^2.7.4", python = ">=3.12.4" },
] |
Use pydantic.v1 right now with pydantic 2. We first need to migrate langchain to support pydantic 2 proper (rather than from the v1 namespace). |
Unfortunately, using the |
Is it coming from langchain dependencies or another dependency? |
In my case, it comes from the underlying Let me see if I can generate a minimal example within LangChain's context. EDIT: On investigating the issue, I have confirmed it is identical to the example documented above. This does raise another question though: if FastAPI doesn't support Pydantic V1 models, how is LangServe able to avoid this very issue? Having said all this, I am happy for you to close this issue (or keep it open for visibility, until Pydantic V2 is fully supported?) |
Just now saw this issue, which is very similar to the one I just filed - #725. In my case, the only reason I upgraded was that I need to update |
Hi this is a documented limitation currently. Please hold off until LangChain 0.3.x. If you want to use pydantic proper 2. You can use pydantic.v1 namespace but FastAPI does not support it. https://github.com/langchain-ai/langserve?tab=readme-ov-file#pydantic |
how can one help with moving langchain to pydantic v2 ? can you point me towards a good starting point to get started ? |
Summary
I am unable to get LangServe to work nicely with a Pydantic V2 model.
Background
I understand that LangChain and LangServe are undergoing an upgrade from Pydantic V1 to V2. I was under the impression that LangServe supports V2 models, with the one caveat that OpenAPI docs aren't presently generated.
Example
Here is a simple reproducible example of the error, along with all installed dependencies and the error logs. The TL;DR is:
langchain-core==0.2.9
langserve==0.2.2
pydantic==2.7.4
Virtual Environment
example.py
Error logs
The text was updated successfully, but these errors were encountered: