mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-03 11:47:49 +00:00
docs: update version docs (#26457)
This commit is contained in:
parent
222caaebdd
commit
fa8e0d90de
@ -85,8 +85,8 @@ Build stateful, multi-actor applications with LLMs. Integrates smoothly with Lan
|
||||
|
||||
## Additional resources
|
||||
|
||||
### [Versions](/docs/versions/overview/)
|
||||
See what changed in v0.2, learn how to migrate legacy code, and read up on our release/versioning policies, and more.
|
||||
### [Versions](/docs/versions/v0_3/)
|
||||
See what changed in v0.3, learn how to migrate legacy code, read up on our versioning policies, and more.
|
||||
|
||||
### [Security](/docs/security)
|
||||
Read up on [security](/docs/security) best practices to make sure you're developing safely with LangChain.
|
||||
|
@ -8,7 +8,7 @@ keywords: [retrievalqa, llmchain, conversationalretrievalchain]
|
||||
|
||||
This code contains a list of deprecations and removals in the `langchain` and `langchain-core` packages.
|
||||
|
||||
New features and improvements are not listed here. See the [overview](/docs/versions/overview/) for a summary of what's new in this release.
|
||||
New features and improvements are not listed here. See the [overview](/docs/versions/v0_2/overview/) for a summary of what's new in this release.
|
||||
|
||||
## Breaking changes
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Migrating to LangChain v0.2
|
||||
# Migration
|
||||
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@ sidebar_position: 2
|
||||
sidebar_label: astream_events v2
|
||||
---
|
||||
|
||||
# Migrating to Astream Events v2
|
||||
# Migrating to astream_events(..., version="v2")
|
||||
|
||||
We've added a `v2` of the astream_events API with the release of `0.2.x`. You can see this [PR](https://github.com/langchain-ai/langchain/pull/21638) for more details.
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
---
|
||||
sidebar_position: 0
|
||||
sidebar_label: Overview of v0.2
|
||||
---
|
||||
|
||||
# Overview of LangChain v0.2
|
||||
# Overview
|
||||
|
||||
## What’s new in LangChain?
|
||||
|
197
docs/docs/versions/v0_3/index.mdx
Normal file
197
docs/docs/versions/v0_3/index.mdx
Normal file
@ -0,0 +1,197 @@
|
||||
# LangChain v0.3
|
||||
|
||||
*Last updated: 09.13.24*
|
||||
|
||||
## What's changed
|
||||
|
||||
* All packages have been upgraded from Pydantic 1 to Pydantic 2 internally. Use of Pydantic 2 in user code is fully supported with all packages without the need for bridges like `langchain_core.pydantic_v1` or `pydantic.v1`.
|
||||
* Pydantic 1 will no longer be supported as it reached its end-of-life in June 2024.
|
||||
* Python 3.8 will no longer be supported as its end-of-life is October 2024.
|
||||
|
||||
**These are the only breaking changes.**
|
||||
|
||||
## What’s new
|
||||
|
||||
The following features have been added during the development of 0.2.x:
|
||||
|
||||
- Moved more integrations from `langchain-community` to their own `langchain-x` packages. This is a non-breaking change, as the legacy implementations are left in `langchain-community` and marked as deprecated. This allows us to better manage the dependencies of, test, and version these integrations. You can see all the latest integration packages in the [API reference](https://python.langchain.com/v0.2/api_reference/reference.html#integrations).
|
||||
- Simplified tool definition and usage. Read more [here](https://blog.langchain.dev/improving-core-tool-interfaces-and-docs-in-langchain/).
|
||||
- Added utilities for interacting with chat models: [universal model constructor](https://python.langchain.com/v0.2/docs/how_to/chat_models_universal_init/), [rate limiter](https://python.langchain.com/v0.2/docs/how_to/chat_model_rate_limiting/), [message utilities](https://python.langchain.com/v0.2/docs/how_to/#messages),
|
||||
- Added the ability to [dispatch custom events](https://python.langchain.com/v0.2/docs/how_to/callbacks_custom_events/).
|
||||
- Revamped integration docs and API reference. Read more [here](https://blog.langchain.dev/langchain-integration-docs-revamped/).
|
||||
- Marked as deprecated a number of legacy chains and added migration guides for all of them. These are slated for removal in `langchain` 1.0.0. See the deprecated chains and associated [migration guides here](https://python.langchain.com/v0.2/docs/versions/migrating_chains/).
|
||||
|
||||
## How to update your code
|
||||
|
||||
If you're using `langchain` / `langchain-community` / `langchain-core` 0.0 or 0.1, we recommend that you first [upgrade to 0.2](https://python.langchain.com/v0.2/docs/versions/v0_2/). The `langchain-cli` will help you to migrate many imports automatically.
|
||||
|
||||
If you're using `langgraph`, upgrade to `langgraph>=0.2.20,<0.3`. This will work with either 0.2 or 0.3 versions of all the base packages.
|
||||
|
||||
Here is a complete list of all packages that have been released and what we recommend upgrading your version constraints to:
|
||||
|
||||
### Base packages
|
||||
|
||||
| Package | Latest | Recommended constraint |
|
||||
| -------------------------------------- | ------- | -------------------------- |
|
||||
| langchain | 0.3.0 | >=0.3,<0.4 |
|
||||
| langchain-community | 0.3.0 | >=0.3,<0.4 |
|
||||
| langchain-text-splitters | 0.3.0 | >=0.3,<0.4 |
|
||||
| langchain-core | 0.3.0 | >=0.3,<0.4 |
|
||||
| langchain-experimental | 0.3.0 | >=0.3,<0.4 |
|
||||
|
||||
### Integration packages
|
||||
|
||||
| Package | Latest | Recommended constraint |
|
||||
| -------------------------------------- | ------- | -------------------------- |
|
||||
| langchain-ai21 | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-aws | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-anthropic | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-astradb | 0.4.1 | >=0.4.1,<0.5 |
|
||||
| langchain-azure-dynamic-sessions | 0.1.1 | >=0.1.1,<0.2 |
|
||||
| langchain-box | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-chroma | 0.1.4 | >=0.1.4,<0.2 |
|
||||
| langchain-cohere | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-elasticsearch | 0.2.3 | >=0.2.3,<0.3 |
|
||||
| langchain-exa | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-fireworks | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-groq | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-google-community | 2.0.0 | >=2,<3 |
|
||||
| langchain-google-genai | 2.0.0 | >=2,<3 |
|
||||
| langchain-google-vertexai | 2.0.0 | >=2,<3 |
|
||||
| langchain-huggingface | 0.1.0 | >=0.1,<0.2 |
|
||||
| langchain-milvus | 0.1.6 | >=0.1.6,<0.2 |
|
||||
| langchain-mistralai | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-mongodb | 0.1.10 | >=0.1.10,<0.2 |
|
||||
| langchain-nomic | 0.1.3 | >=0.1.3,<0.2 |
|
||||
| langchain-ollama | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-openai | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-pinecone | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-postgres | 0.0.13 | >=0.0.13,<0.1 |
|
||||
| langchain-prompty | 0.1.0 | >=0.1,<0.2 |
|
||||
| langchain-qdrant | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-together | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-unstructured | 0.1.4 | >=0.1.4,<0.2 |
|
||||
| langchain-voyageai | 0.2.0 | >=0.2,<0.3 |
|
||||
| langchain-weaviate | 0.1.0 | >=0.1,<0.2 |
|
||||
|
||||
Once you've updated to recent versions of the packages, you may need to address the following issues stemming from the internal switch from Pydantic v1 to Pydantic v2:
|
||||
|
||||
- If your code depends on Pydantic aside from LangChain, you will need to upgrade your pydantic version constraints to be `pydantic>=2,<3`. See [Pydantic’s migration guide](https://docs.pydantic.dev/latest/migration/) for help migrating your non-LangChain code to Pydantic v2 if you use pydantic v1.
|
||||
- There are a number of side effects to LangChain components caused by the internal switch from Pydantic v1 to v2. We have listed some of the common cases below together with the recommended solutions.
|
||||
|
||||
## Common issues when transitioning to Pydantic 2
|
||||
|
||||
### 1. Do not use the `langchain_core.pydantic_v1` namespace
|
||||
|
||||
Replace any usage of `langchain_core.pydantic_v1` or `langchain.pydantic_v1` with
|
||||
direct imports from `pydantic`.
|
||||
|
||||
For example,
|
||||
|
||||
```python
|
||||
from langchain_core.pydantic_v1 import BaseModel
|
||||
```
|
||||
|
||||
to:
|
||||
|
||||
```python
|
||||
from pydantic import BaseModel
|
||||
```
|
||||
|
||||
This may require you to make additional updates to your Pydantic code given that there are a number of breaking changes in Pydantic 2. See the [Pydantic Migration](https://docs.pydantic.dev/latest/migration/) for how to upgrade your code from Pydantic 1 to 2.
|
||||
|
||||
### 2. Passing Pydantic objects to LangChain APIs
|
||||
|
||||
Users using the following APIs:
|
||||
|
||||
* `BaseChatModel.bind_tools`
|
||||
* `BaseChatModel.with_structured_output`
|
||||
* `Tool.from_function`
|
||||
* `StructuredTool.from_function`
|
||||
|
||||
should ensure that they are passing Pydantic 2 objects to these APIs rather than
|
||||
Pydantic 1 objects (created via the `pydantic.v1` namespace of pydantic 2).
|
||||
|
||||
:::caution
|
||||
While `v1` objets may be accepted by some of these APIs, users are advised to
|
||||
use Pydantic 2 objects to avoid future issues.
|
||||
:::
|
||||
|
||||
### 3. Sub-classing LangChain models
|
||||
|
||||
Any sub-classing from existing LangChain models (e.g., `BaseTool`, `BaseChatModel`, `LLM`)
|
||||
should upgrade to use Pydantic 2 features.
|
||||
|
||||
For example, any user code that's relying on Pydantic 1 features (e.g., `validator`) should
|
||||
be updated to the Pydantic 2 equivalent (e.g., `field_validator`), and any references to
|
||||
`pydantic.v1`, `langchain_core.pydantic_v1`, `langchain.pydantic_v1` should be replaced
|
||||
with imports from `pydantic`.
|
||||
|
||||
```python
|
||||
from pydantic.v1 import validator, Field # if pydantic 2 is installed
|
||||
# from pydantic import validator, Field # if pydantic 1 is installed
|
||||
# from langchain_core.pydantic_v1 import validator, Field
|
||||
# from langchain.pydantic_v1 import validator, Field
|
||||
|
||||
class CustomTool(BaseTool): # BaseTool is v1 code
|
||||
x: int = Field(default=1)
|
||||
|
||||
def _run(*args, **kwargs):
|
||||
return "hello"
|
||||
|
||||
@validator('x') # v1 code
|
||||
@classmethod
|
||||
def validate_x(cls, x: int) -> int:
|
||||
return 1
|
||||
```
|
||||
|
||||
Should change to:
|
||||
|
||||
```python
|
||||
from pydantic import Field, field_validator # pydantic v2
|
||||
from langchain_core.pydantic_v1 import BaseTool
|
||||
|
||||
class CustomTool(BaseTool): # BaseTool is v1 code
|
||||
x: int = Field(default=1)
|
||||
|
||||
def _run(*args, **kwargs):
|
||||
return "hello"
|
||||
|
||||
@field_validator('x') # v2 code
|
||||
@classmethod
|
||||
def validate_x(cls, x: int) -> int:
|
||||
return 1
|
||||
|
||||
|
||||
CustomTool(
|
||||
name='custom_tool',
|
||||
description="hello",
|
||||
x=1,
|
||||
)
|
||||
```
|
||||
|
||||
### 4. model_rebuild()
|
||||
|
||||
When sub-classing from LangChain models, users may need to add relevant imports
|
||||
to the file and rebuild the model.
|
||||
|
||||
```python
|
||||
from langchain_core.output_parsers import BaseOutputParser
|
||||
|
||||
|
||||
class FooParser(BaseOutputParser):
|
||||
...
|
||||
```
|
||||
|
||||
New code:
|
||||
|
||||
```python
|
||||
from typing import Optional as Optional
|
||||
|
||||
from langchain_core.output_parsers import BaseOutputParser
|
||||
|
||||
class FooParser(BaseOutputParser):
|
||||
...
|
||||
|
||||
FooParser.model_rebuild()
|
||||
```
|
@ -72,25 +72,24 @@ module.exports = {
|
||||
collapsed: false,
|
||||
collapsible: false,
|
||||
items: [
|
||||
"versions/v0_3/overview",
|
||||
"versions/overview",
|
||||
{
|
||||
type: 'doc',
|
||||
id: 'versions/v0_3/index',
|
||||
label: "v0.3",
|
||||
},
|
||||
{
|
||||
type: "category",
|
||||
label: "v0.2",
|
||||
items: [{
|
||||
type: 'autogenerated',
|
||||
dirName: 'versions/v0_2',
|
||||
}],
|
||||
},
|
||||
{
|
||||
type: 'doc',
|
||||
id: "how_to/pydantic_compatibility",
|
||||
label: "Pydantic compatibility",
|
||||
},
|
||||
{
|
||||
type: "category",
|
||||
label: "Migrating to v0.2",
|
||||
link: {type: 'doc', id: 'versions/v0_2/index'},
|
||||
collapsible: false,
|
||||
collapsed: false,
|
||||
items: [{
|
||||
type: 'autogenerated',
|
||||
dirName: 'versions/v0_2',
|
||||
className: 'hidden',
|
||||
}],
|
||||
},
|
||||
{
|
||||
type: "category",
|
||||
label: "Migrating from v0.0 chains",
|
||||
|
@ -26,6 +26,10 @@
|
||||
}
|
||||
],
|
||||
"redirects": [
|
||||
{
|
||||
"source": "/docs/versions/overview(/?)",
|
||||
"destination": "/docs/versions/v0_2/overview/"
|
||||
},
|
||||
{
|
||||
"source": "/docs/how_to/tool_calls_multi_modal(/?)",
|
||||
"destination": "/docs/how_to/multimodal_inputs/"
|
||||
|
Loading…
Reference in New Issue
Block a user