-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2.x] Upgrade to LangChain v0.3 and Pydantic v2 (#1199)
* remove importliner from project * initial upgrade to langchain~=0.3, pydantic~=2.0 * default to `None` for all `Optional` fields explicitly * fix history impl for Pydantic v2, fixes chat * prefer `.model_dump_json()` over `.json()` Addresses a Pydantic v2 deprecation warning, as `BaseModel.json()` is now deprecated in favor of `BaseModel.model_dump_json()`. * replace `.dict()` with `.model_dump()`. `BaseModel.dict()` is deprecated in favor of `BaseModel.model_dump()` in Pydantic v2. * fix BaseProvider.server_settings * fix OpenRouterProvider * fix remaining unit tests * address all Pydantic v1 deprecation warnings * pre-commit * fix mypy
- Loading branch information
Showing
27 changed files
with
189 additions
and
271 deletions.
There are no files selected for viewing
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from langchain.pydantic_v1 import BaseModel | ||
from pydantic import BaseModel | ||
|
||
|
||
class Persona(BaseModel): | ||
|
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 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 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
27 changes: 27 additions & 0 deletions
27
packages/jupyter-ai-magics/jupyter_ai_magics/tests/test_base_provider.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import ClassVar, Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
from ..providers import BaseProvider | ||
|
||
|
||
def test_provider_classvars(): | ||
""" | ||
Asserts that class attributes are not omitted due to parent classes defining | ||
an instance field of the same name. This was a bug present in Pydantic v1, | ||
which led to an issue documented in #558. | ||
This bug is fixed as of `pydantic==2.10.2`, but we will keep this test in | ||
case this behavior changes in future releases. | ||
""" | ||
|
||
class Parent(BaseModel): | ||
test: Optional[str] = None | ||
|
||
class Base(BaseModel): | ||
test: ClassVar[str] | ||
|
||
class Child(Base, Parent): | ||
test: ClassVar[str] = "expected" | ||
|
||
assert Child.test == "expected" |
Oops, something went wrong.