-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage #22819
Labels
help wanted
Good issue for contributors
Ɑ: pydantic
Related to pydantic or pydantic migration
🤖:refactor
A large refactor of a feature(s) or restructuring of many files
Comments
dosubot
bot
added
Ɑ: pydantic
Related to pydantic or pydantic migration
🤖:refactor
A large refactor of a feature(s) or restructuring of many files
labels
Jun 12, 2024
eyurtsev
changed the title
Help prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage
Jun 12, 2024
eyurtsev
changed the title
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage (Not Open For Sign Yet)
Jun 12, 2024
eyurtsev
changed the title
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage (Not Open For Sign Yet)
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage (Not Open For Sign-up Yet)
Jun 12, 2024
eyurtsev
changed the title
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage (Not Open For Sign-up Yet)
Prepare for pydantic 2 migration by refactoring vanilla @root_validator() usage
Jun 12, 2024
eyurtsev
added a commit
that referenced
this issue
Jun 20, 2024
…anfanChatEndpoint, MiniMaxChat, ChatSparkLLM, ChatZhipuAI (#22853) This PR updates root validators for: - ChatModels: ChatBaichuan, QianfanChatEndpoint, MiniMaxChat, ChatSparkLLM, ChatZhipuAI Issues #22819 --------- Co-authored-by: Eugene Yurtsev <[email protected]>
hinthornw
pushed a commit
that referenced
this issue
Jun 20, 2024
…anfanChatEndpoint, MiniMaxChat, ChatSparkLLM, ChatZhipuAI (#22853) This PR updates root validators for: - ChatModels: ChatBaichuan, QianfanChatEndpoint, MiniMaxChat, ChatSparkLLM, ChatZhipuAI Issues #22819 --------- Co-authored-by: Eugene Yurtsev <[email protected]>
eyurtsev
added a commit
that referenced
this issue
Jun 26, 2024
…3256) Description: update agent and chains modules Pydantic root_validators. Issue: the issue #22819 --------- Co-authored-by: gongwn1 <[email protected]> Co-authored-by: Eugene Yurtsev <[email protected]> Co-authored-by: Eugene Yurtsev <[email protected]>
This was referenced Jul 1, 2024
eyurtsev
added a commit
that referenced
this issue
Jul 2, 2024
eyurtsev
pushed a commit
that referenced
this issue
Jul 2, 2024
Description: 1. partners/HuggingFace module support reading params from env. Not adjust langchain_community/.../huggingfaceXX modules since they are deprecated. 2. pydantic 2 @root_validator migration. Issue: #22448 #22819 --------- Co-authored-by: gongwn1 <[email protected]>
eyurtsev
added a commit
that referenced
this issue
Jul 2, 2024
Update all utilities to use `pre=True` or `pre=False` #22819
Maybe superseded by: #23841 |
This was referenced Jul 4, 2024
ccurme
pushed a commit
that referenced
this issue
Jul 5, 2024
Description: add model_name param valid for GPT4AllEmbeddings Issue: #23863 #22819 --------- Co-authored-by: gongwn1 <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
help wanted
Good issue for contributors
Ɑ: pydantic
Related to pydantic or pydantic migration
🤖:refactor
A large refactor of a feature(s) or restructuring of many files
Privileged issue
Issue Content
Context
Currently, LangChain supports Pydantic 2 only through the v1 namespace.
The plan is to transition for Pydantic 2 with release 0.3.0 of LangChain, and drop support for Pydantic 1.
LangChain has around ~1000 pydantic objects across different packages While LangChain uses a number of deprecated features, one of the harder things to update is the usage of a vanilla
@root_validator()
(which is used ~250 times across the code base).The goal of this issue is to do as much preliminary work as possible to help prepare for the migration from pydantic v1 to pydantic 2.
To help prepare for the migration, we'll need to refactor each occurrence of a vanilla
root_validator()
to one of the following 3 variants (depending on what makes sense in the context of the model):root_validator(pre=True)
-- pre initialization validatorroot_validator(pre=False, skip_on_failure=True)
-- post initialization validatorroot_validator(pre=True)
ANDroot_validator(pre=False, skip_on_failure=True)
to include both pre initialization and post initialization validation.Guidelines
What not to do
model_validator
. We're trying to break the work into small chunks that can be done while we're still using Pydantic v1 functionality!field_validators
when doing the refactor.Simple Example
After refactor
Example Refactors
Here are some actual for the refactors https://gist.github.com/eyurtsev/be30ddbc54dcdc02f98868eacb24b2a1
If you're feeling especially creative, you could try to use the example refactors, an LLM chain built with an appropriate prompt to attempt to automatically fix this code using LLMs!
Vanilla `root_validator
The text was updated successfully, but these errors were encountered: