-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
community[patch]: Skip broken unit test that depends on langchain-aws in env, fix pydantic_settings #26110
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR upgrades core to pydantic 2. It involves a combination of manual changes together with automated code mods using gritql. Changes and known issues: 1. Current models override __repr__ to be consistent with pydantic 1 (this will be removed in a follow up PR) Related: https://github.com/langchain-ai/langchain/pull/25986/files#diff-e5bd296179b7a72fcd4ea5cfa28b145beaf787da057e6d122aa76ee0bb8132c9R74 2. Issue with decorator for BaseChatModel (https://github.com/langchain-ai/langchain/pull/25986/files#diff-932bf3b314b268754ef640a5b8f52da96f9024fb81dd388dcd166b5713ecdf66R202) -- cc @baskaryan 3. `name` attribute in Base Runnable does not have a default -- was raising a pydantic warning due to override. We need to see if there's a way to fix to avoid making a breaking change for folks with custom runnables. (https://github.com/langchain-ai/langchain/pull/25986/files#diff-836773d27f8565f4dd45e9d6cf828920f89991a880c098b7511e0d3bb78a8a0dR238) 4. Likely can remove hard-coded RunnableBranch name (https://github.com/langchain-ai/langchain/pull/25986/files#diff-72894b94f70b1bfc908eb4d53f5ff90bb33bf8a4240a5e34cae48ddc62ac313aR147) 5. `model_*` namespace is reserved in pydantic. We'll need to specify `protected_namespaces` 6. create_model does not have a cached path yet 7. get_input_schema() in many places has been updated to be explicit about whether parameters are required or optional 8. injected tool args aren't picked up properly (losing type annotation) For posterity the following gritql migrations were used: ``` engine marzano(0.1) language python or { `from $IMPORT import $...` where { $IMPORT <: contains `pydantic_v1`, $IMPORT => `pydantic` }, `$X.update_forward_refs` => `$X.model_rebuild`, // This pattern still needs fixing as it fails (populate_by_name vs. // allow_populate_by_name) class_definition($name, $body) as $C where { $name <: `Config`, $body <: block($statements), $t = "", $statements <: some bubble($t) assignment(left=$x, right=$y) as $A where { or { $x <: `allow_population_by_field_name` where { $t += `populate_by_name=$y,` }, $t += `$x=$y,` } }, $C => `model_config = ConfigDict($t)`, add_import(source="pydantic", name="ConfigDict") } } ``` ``` engine marzano(0.1) language python `@root_validator(pre=True)` as $decorator where { $decorator <: before function_definition($body, $return_type), $decorator => `@model_validator(mode="before")\n@classmethod`, add_import(source="pydantic", name="model_validator"), $return_type => `Any` } ``` ``` engine marzano(0.1) language python `@root_validator(pre=False, skip_on_failure=True)` as $decorator where { $decorator <: before function_definition($body, $parameters, $return_type) where { $body <: contains bubble or { `values["$Q"]` => `self.$Q`, `values.get("$Q")` => `(self.$Q or None)`, `values.get($Q, $...)` as $V where { $Q <: contains `"$QName"`, $V => `self.$QName`, }, `return $Q` => `return self` } }, $decorator => `@model_validator(mode="after")`, // Silly work around a bug in grit // Adding Self to pydantic and then will replace it with one from typing add_import(source="pydantic", name="model_validator"), $parameters => `self`, $return_type => `Self` } ``` ``` grit apply --language python '`Self` where { add_import(source="typing_extensions", name="Self")}' ```
Drop python 3.8 support as EOL is 2024 October
Co-authored-by: Dan O'Donovan <[email protected]> Co-authored-by: Tom Daniel Grande <[email protected]> Co-authored-by: Grande <[email protected]> Co-authored-by: Erick Friis <[email protected]> Co-authored-by: Eugene Yurtsev <[email protected]>
- Fix injected args in tool signature - Fix another unit test that was using the wrong namespace import in pydantic
Upgrading the langchain package to be pydantic 2 compatible. Had to remove some parts of unit tests in parsers that were relying on spying on methods since that fails with pydantic 2. The unit tests don't seem particularly good, so can be re-written at a future date. Depends on: #26057 Most of this PR was done using gritql for code mods, followed by some fixes done manually to account for changes made by pydantic
…fig_jsonschema (#26034) This PR adds methods to directly get the json schema for inputs, outputs, and config. Currently, it's delegating to the underlying pydantic implementation, but this may be changed in the future to be independent of pydantic.
Add type overload
This repr will be deleted prior to release -- it's temporarily here to make it easy to separate code changes in langchain vs. code changes stemming from breaking changes in pydantic
This PR upgrades langchain-community to pydantic 2. * Most of this PR was auto-generated using code mods with gritql (https://github.com/eyurtsev/migrate-pydantic/tree/main) * Subsequently, some code was fixed manually due to accommodate differences between pydantic 1 and 2 Breaking Changes: - Use TEXTEMBED_API_KEY and TEXTEMBEB_API_URL for env variables for text embed integrations: cbea780 Other changes: - Added pydantic_settings as a required dependency for community. This may be removed if we have enough time to convert the dependency into an optional one. --------- Co-authored-by: Eugene Yurtsev <[email protected]> Co-authored-by: Bagatur <[email protected]>
dosubot
bot
added
the
size:L
This PR changes 100-499 lines, ignoring generated files.
label
Sep 5, 2024
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for contributing to LangChain!
PR title: "package: description"
PR message: Delete this entire checklist and replace with
Add tests and docs: If you're adding a new integration, please include
docs/docs/integrations
directory.Lint and test: Run
make format
,make lint
andmake test
from the root of the package(s) you've modified. See contribution guidelines for more: https://python.langchain.com/docs/contributing/Additional guidelines:
If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.