Skip to content

Commit 92262ba

Browse files
Backport PR #1204: Update developer docs on Pydantic compatibility (#1206)
Co-authored-by: David L. Qiu <[email protected]>
1 parent 26593dc commit 92262ba

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

docs/source/developers/index.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,28 @@ please see our {doc}`contributor's guide </contributors/index>`.
88

99
## Pydantic compatibility
1010

11-
Jupyter AI is fully compatible with Python environments using Pydantic v1
12-
or Pydantic v2. Jupyter AI imports Pydantic classes from the
13-
`langchain.pydantic_v1` module. Developers should do the same when they extend
14-
Jupyter AI classes.
15-
16-
For more details about using `langchain.pydantic_v1` in an environment with
17-
Pydantic v2 installed, see the
18-
[LangChain documentation on Pydantic compatibility](https://python.langchain.com/docs/guides/pydantic_compatibility).
11+
- `jupyter-ai<2.29.0` requires Pydantic v1 **or** v2, but only supports
12+
LangChain v0.2, which is now outdated.
13+
14+
- Internally, `jupyter-ai<2.29.0` uses the Pydantic v1 API through a
15+
vendored module provided by LangChain. Therefore, if you are developing
16+
extensions for `jupyter-ai<2.29.0`, you should import Pydantic objects (e.g.
17+
`BaseModel`) from the `langchain.pydantic_v1` module. In this context, you
18+
should *not* use the `pydantic` module (as it may be Pydantic v1 or v2).
19+
20+
- `jupyter-ai>=2.29.0` requires Pydantic v2 (**not** v1), but supports LangChain
21+
`>=0.3`.
22+
23+
- Internally, `jupyter-ai>=2.29.0` uses the Pydantic v2 API directly through
24+
the `pydantic` module. Therefore, if you are developing extensions for
25+
`jupyter-ai>=2.29.0`, you should import Pydantic objects (e.g. `BaseModel`)
26+
from the `pydantic` module.
27+
28+
- For context, LangChain v0.3 requires Pydantic v2. This motivated the
29+
upgrade to the Pydantic v2 API.
30+
31+
For more details about Pydantic & LangChain version compatibility, see the
32+
[LangChain documentation on Pydantic compatibility](https://python.langchain.com/docs/how_to/pydantic_compatibility/).
1933

2034
## Jupyter AI module cookiecutter
2135

0 commit comments

Comments
 (0)