Skip to content
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

Backport PR #1204 on branch 2.x (Update developer docs on Pydantic compatibility) #1206

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions docs/source/developers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,28 @@ please see our {doc}`contributor's guide </contributors/index>`.

## Pydantic compatibility

Jupyter AI is fully compatible with Python environments using Pydantic v1
or Pydantic v2. Jupyter AI imports Pydantic classes from the
`langchain.pydantic_v1` module. Developers should do the same when they extend
Jupyter AI classes.

For more details about using `langchain.pydantic_v1` in an environment with
Pydantic v2 installed, see the
[LangChain documentation on Pydantic compatibility](https://python.langchain.com/docs/guides/pydantic_compatibility).
- `jupyter-ai<2.29.0` requires Pydantic v1 **or** v2, but only supports
LangChain v0.2, which is now outdated.

- Internally, `jupyter-ai<2.29.0` uses the Pydantic v1 API through a
vendored module provided by LangChain. Therefore, if you are developing
extensions for `jupyter-ai<2.29.0`, you should import Pydantic objects (e.g.
`BaseModel`) from the `langchain.pydantic_v1` module. In this context, you
should *not* use the `pydantic` module (as it may be Pydantic v1 or v2).

- `jupyter-ai>=2.29.0` requires Pydantic v2 (**not** v1), but supports LangChain
`>=0.3`.

- Internally, `jupyter-ai>=2.29.0` uses the Pydantic v2 API directly through
the `pydantic` module. Therefore, if you are developing extensions for
`jupyter-ai>=2.29.0`, you should import Pydantic objects (e.g. `BaseModel`)
from the `pydantic` module.

- For context, LangChain v0.3 requires Pydantic v2. This motivated the
upgrade to the Pydantic v2 API.

For more details about Pydantic & LangChain version compatibility, see the
[LangChain documentation on Pydantic compatibility](https://python.langchain.com/docs/how_to/pydantic_compatibility/).

## Jupyter AI module cookiecutter

Expand Down
Loading