You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/oss/javascript/migrate/langchain-v1.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: LangChain v1 migration guide
3
-
sidebarTitle: Migration guide
3
+
sidebarTitle: v1 Migration guide
4
4
---
5
5
6
6
This migration guide outlines the major changes in LangChain v1. To learn more about the new features of v1, see the [introductory post](/oss/releases/langchain-v1).
*[Model profiles](/oss/langchain/models#model-profiles): Chat models now expose supported features and capabilities through a `.profile` getter. These data are derived from [models.dev](https://github.com/sst/models.dev), an open source project providing model capability data.
12
-
*[Model retry middleware](/oss/langchain/middleware/built-in#model-retry): New middleware for automatically retrying failed model calls with configurable exponential backoff, improving agent reliability.
13
-
*[Content moderation middleware](/oss/langchain/middleware/built-in#content-moderation): OpenAI content moderation middleware for detecting and handling unsafe content in agent interactions. Supports checking user input, model output, and tool results.
14
-
*[Summarization middleware](/oss/langchain/middleware/built-in#summarization): Updated to support flexible trigger points using model profiles for context-aware summarization.
15
-
*[Structured output](/oss/langchain/structured-output): `ProviderStrategy` support (native structured output) can now be inferred from model profiles.
16
-
*[`SystemMessage` for `createAgent`](/oss/langchain/middleware/custom#working-with-system-messages): Support for passing `SystemMessage` instances directly to `createAgent`'s `systemPrompt` parameter and a new `concat` method for extending system messages. Enables advanced features like cache control and structured content blocks.
17
-
*[Dynamic system prompt middleware](/oss/langchain/agents#dynamic-system-prompt): Return values from `dynamicSystemPromptMiddleware` are now purely additive. When returning a @[`SystemMessage`] or `string`, they are merged with existing system messages rather than replacing them, making it easier to compose multiple middleware that modify the prompt.
18
-
***Compatibility improvements:** Fixed error handling for Zod v4 validation errors in structured output and tool schemas, ensuring detailed error messages are properly displayed.
11
+
*[Model profiles](/oss/langchain/models#model-profiles): Chat models now expose supported features and capabilities through a `.profile` getter. These data are derived from [models.dev](https://models.dev), an open source project providing model capability data.
12
+
*[Model retry middleware](/oss/langchain/middleware/built-in#model-retry): New middleware for automatically retrying failed model calls with configurable exponential backoff, improving agent reliability.
13
+
*[Content moderation middleware](/oss/langchain/middleware/built-in#content-moderation): OpenAI content moderation middleware for detecting and handling unsafe content in agent interactions. Supports checking user input, model output, and tool results.
14
+
*[Summarization middleware](/oss/langchain/middleware/built-in#summarization): Updated to support flexible trigger points using model profiles for context-aware summarization.
15
+
*[Structured output](/oss/langchain/structured-output): `ProviderStrategy` support (native structured output) can now be inferred from model profiles.
16
+
*[`SystemMessage` for `createAgent`](/oss/langchain/middleware/custom#working-with-system-messages): Support for passing `SystemMessage` instances directly to `createAgent`'s `systemPrompt` parameter and a new `concat` method for extending system messages. Enables advanced features like cache control and structured content blocks.
17
+
*[Dynamic system prompt middleware](/oss/langchain/agents#dynamic-system-prompt): Return values from `dynamicSystemPromptMiddleware` are now purely additive. When returning a @[`SystemMessage`] or `string`, they are merged with existing system messages rather than replacing them, making it easier to compose multiple middleware that modify the prompt.
18
+
***Compatibility improvements:** Fixed error handling for Zod v4 validation errors in structured output and tool schemas, ensuring detailed error messages are properly displayed.
Copy file name to clipboardExpand all lines: src/oss/langchain/models.mdx
+77-62Lines changed: 77 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1204,7 +1204,8 @@ LangChain supports all major model providers, including OpenAI, Anthropic, Googl
1204
1204
<Info> Model profiles require `langchain>=1.1`. </Info>
1205
1205
1206
1206
:::python
1207
-
LangChain chat models expose supported features and capabilities through a `.profile` attribute:
1207
+
LangChain chat models can expose a dictionary of supported features and capabilities through a `.profile` attribute:
1208
+
1208
1209
```python
1209
1210
model.profile
1210
1211
# {
@@ -1215,67 +1216,76 @@ model.profile
1215
1216
# ...
1216
1217
# }
1217
1218
```
1218
-
Refer to the full set of fields in the [API reference](https://reference.langchain.com/python/langchain_core/language_models/).
1219
+
1220
+
Refer to the full set of fields in the [API reference](https://reference.langchain.com/python/langchain_core/language_models/#langchain_core.language_models.BaseChatModel.profile).
1219
1221
1220
1222
Much of the model profile data is powered by the [models.dev](https://github.com/sst/models.dev) project, an open source initiative that provides model capability data. These data are augmented with additional fields for purposes of use with LangChain. These augmentations are kept aligned with the upstream project as it evolves.
1221
1223
1222
1224
Model profile data allow applications to work around model capabilities dynamically. For example:
1225
+
1223
1226
1. [Summarization middleware](/oss/langchain/middleware/built-in#summarization) can trigger summarization based on a model's context window size.
1224
1227
2. [Structured output](/oss/langchain/structured-output) strategies in `create_agent` can be inferred automatically (e.g., by checking support for native structured output features).
1225
1228
3. Model inputs can be gated based on supported [modalities](#multimodal) and maximum input tokens.
1226
1229
1227
-
#### Updating or overwriting profile data
1228
-
Model profile data can be changed if it is missing, stale, or incorrect.
1230
+
<Accordion title="Modify profile data">
1231
+
Model profile data can be changed if it is missing, stale, or incorrect.
1229
1232
1230
-
**Option 1 (quick fix)**
1233
+
**Option 1 (quick fix)**
1231
1234
1232
-
You can instantiate a chat model with any valid profile:
The `profile` is also a regular `dict` and can be updated in place. If the model instance is shared, consider using `model_copy` to avoid mutating shared state.
1251
1248
1252
-
The primary source for the data is the [models.dev](https://models.dev/) project. These data are merged with additional fields and overrides in LangChain [integration packages](/oss/integrations/providers/overview) and are shipped with those packages.
1249
+
```python
1250
+
new_profile=model.profile| {"key": "value"}
1251
+
model.model_copy(update={"profile": new_profile})
1252
+
```
1253
1253
1254
-
Model profile data can be updated through the following process:
1255
-
1. (If needed) update the source data at [models.dev](https://models.dev/) through a pull request to its [repository on Github](https://github.com/sst/models.dev).
1256
-
2. (If needed) update additional fields and overrides in `langchain_<package>/data/profile_augmentations.toml` through a pull request to the LangChain [integration package](/oss/integrations/providers/overview)`.
1257
-
3.Usethe [langchain-model-profiles](https://pypi.org/project/langchain-model-profiles/) CLI tool to pull the latest data from [models.dev](https://models.dev/), merge in the augmentations and update the profile data:
Example, from [libs/partners/anthropic](https://github.com/langchain-ai/langchain/tree/master/libs/partners/anthropic) in the LangChain monorepo:
1271
-
```bash
1272
-
uv run --with langchain-model-profiles --provider anthropic --data-dir langchain_anthropic/data
1273
-
```
1256
+
The primary source for the data is the [models.dev](https://models.dev/) project. This data is merged with additional fields and overrides in LangChain [integration packages](/oss/integrations/providers/overview) and are shipped with those packages.
1257
+
1258
+
Model profile data can be updated through the following process:
1259
+
1260
+
1. (If needed) update the source data at [models.dev](https://models.dev/) through a pull request to its [repository on Github](https://github.com/sst/models.dev).
1261
+
2. (If needed) update additional fields and overrides in `langchain_<package>/data/profile_augmentations.toml` through a pull request to the LangChain [integration package](/oss/integrations/providers/overview)`.
1262
+
3.Usethe [`langchain-model-profiles`](https://pypi.org/project/langchain-model-profiles/) CLI tool to pull the latest data from [models.dev](https://models.dev/), merge in the augmentations and update the profile data:
Forexample: from [`libs/partners/anthropic`](https://github.com/langchain-ai/langchain/tree/master/libs/partners/anthropic) in the [LangChain monorepo](https://github.com/langchain-ai/langchain):
1278
+
1279
+
```bash
1280
+
uv run --with langchain-model-profiles --provider anthropic --data-dir langchain_anthropic/data
Muchofthemodelprofiledataispoweredbythe [models.dev](https://github.com/sst/models.dev) project, an open source initiative that provides model capability data. These data are augmented with additional fields for purposes of use with LangChain. These augmentations are kept aligned with the upstream project as it evolves.
1302
+
Muchofthemodelprofiledataispoweredbythe [models.dev](https://github.com/sst/models.dev) project, an open source initiative that provides model capability data. This data is augmented with additional fields for purposes of use with LangChain. These augmentations are kept aligned with the upstream project as it evolves.
Model profile data can be changed if it is missing, stale, or incorrect.
1300
1312
1301
-
**Option1 (quickfix)**
1313
+
**Option 1 (quick fix)**
1302
1314
1303
-
Youcaninstantiateachatmodelwithanyvalidprofile:
1304
-
```typescript
1305
-
const customProfile = {
1306
-
maxInputTokens: 100_000,
1307
-
toolCalling: true,
1308
-
structuredOutput: true,
1309
-
// ...
1310
-
};
1311
-
const model = initChatModel("...", { profile: customProfile });
1312
-
```
1315
+
You can instantiate a chat model with any valid profile:
1313
1316
1314
-
**Option2 (fixdataupstream)**
1317
+
```typescript
1318
+
const customProfile = {
1319
+
maxInputTokens: 100_000,
1320
+
toolCalling: true,
1321
+
structuredOutput: true,
1322
+
// ...
1323
+
};
1324
+
const model = initChatModel("...", {profile: customProfile});
1325
+
```
1326
+
1327
+
**Option 2 (fix data upstream)**
1315
1328
1316
-
Theprimarysourceforthedataisthe [models.dev](https://models.dev/) project. These data are merged with additional fields and overrides in LangChain [integration packages](/oss/integrations/providers/overview) and are shipped with those packages.
1329
+
The primary source for the data is the [models.dev](https://models.dev/) project. These data are merged with additional fields and overrides in LangChain [integration packages](/oss/integrations/providers/overview) and are shipped with those packages.
1. (Ifneeded) updatethesourcedataat [models.dev](https://models.dev/) through a pull request to its [repository on Github](https://github.com/sst/models.dev).
Model profile data can be updated through the following process:
1332
+
1333
+
1. (If needed) update the source data at [models.dev](https://models.dev/) through a pull request to its [repository on Github](https://github.com/sst/models.dev).
1334
+
2. (If needed) update additional fields and overrides in `langchain-<package>/profiles.toml` through a pull request to the LangChain [integration package](/oss/integrations/providers/overview).
For a complete list of changes and instructions on how to upgrade your code, see the [release notes](/oss/releases/langchain-v1) and [migration guide](/oss/migrate/langchain-v1).
For a complete list of changes and instructions on how to upgrade your code, see the [release notes](/oss/releases/langchain-v1) and [migration guide](/oss/migrate/langchain-v1).
0 commit comments