Skip to content

Commit 7c9605d

Browse files
davidkna-sapdeekshas8ZhongpinWang
authored
feat!: Update langchain to v1 (#1187)
* Update langchain to v1 alpha * feat: upgrade zod to v4 * bump to langchain v1 release * fix: use `switch` instead of `instanceof` again * format * re-add deprecated`additional_kwargs.tool_calls` * chore: bump langchain packages * pnpm local * workaround for cjs compilation * check dep fix * update pnpm lock file * chore: fix tests by bumping zod to v4 * chore: bump langchain * fix: api updates * chore: create changeset * fix: revert sample-code to zod@3 for mcp-support * chore: add compatibility note for zod v4 * Squashed commit of the following: commit 4be7379 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu Nov 20 15:16:05 2025 +0100 chore(deps-dev): Bump glob from 12.0.0 to 13.0.0 (#1289) Bumps [glob](https://github.com/isaacs/node-glob) from 12.0.0 to 13.0.0. - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](isaacs/node-glob@v12.0.0...v13.0.0) --- updated-dependencies: - dependency-name: glob dependency-version: 13.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit eb1e0b1 Author: SAP Cloud SDK Bot <[email protected]> Date: Thu Nov 20 10:26:27 2025 +0100 chore: update pnpm transitive dependencies (#1291) Co-authored-by: cloud-sdk-js <[email protected]> commit 6b8c656 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu Nov 20 10:06:13 2025 +0100 chore(deps): Bump glob from 10.4.5 to 12.0.0 (#1288) commit 1b18386 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue Nov 18 09:21:50 2025 +0100 chore(deps): Bump glob from 10.4.5 to 11.1.0 (#1284) Bumps [glob](https://github.com/isaacs/node-glob) from 10.4.5 to 11.1.0. - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](isaacs/node-glob@v10.4.5...v11.1.0) --- updated-dependencies: - dependency-name: glob dependency-version: 11.1.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit eeeeb29 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue Nov 18 09:21:39 2025 +0100 chore(deps-dev): Bump glob from 11.0.3 to 12.0.0 (#1280) Bumps [glob](https://github.com/isaacs/node-glob) from 11.0.3 to 12.0.0. - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](isaacs/node-glob@v11.0.3...v12.0.0) --- updated-dependencies: - dependency-name: glob dependency-version: 12.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 9e04c3a Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue Nov 18 00:34:24 2025 +0000 chore(deps-dev): Bump glob from 11.0.3 to 11.1.0 (#1283) Bumps [glob](https://github.com/isaacs/node-glob) from 11.0.3 to 11.1.0. - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](isaacs/node-glob@v11.0.3...v11.1.0) --- updated-dependencies: - dependency-name: glob dependency-version: 11.1.0 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 34c466f Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue Nov 18 00:30:12 2025 +0000 chore(deps): Bump @modelcontextprotocol/sdk from 1.21.1 to 1.22.0 (#1279) Bumps [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk) from 1.21.1 to 1.22.0. - [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases) - [Commits](modelcontextprotocol/typescript-sdk@1.21.1...1.22.0) --- updated-dependencies: - dependency-name: "@modelcontextprotocol/sdk" dependency-version: 1.22.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit 4158a81 Author: David Knaack <[email protected]> Date: Mon Nov 17 12:48:46 2025 +0100 chore(lint): Be more permissive with/ignore generated cjs files (#1277) * chore(eslint): Be more permissive with generated cjs files * chore(prettier): ignore dist-cjs --------- Co-authored-by: Zhongpin Wang <[email protected]> commit 69a76be Author: David Knaack <[email protected]> Date: Mon Nov 17 12:33:19 2025 +0100 fix: Improve reliability of Spec File Update Workflow (#1278) commit c155302 Author: sap-ai-sdk <[email protected]> Date: Mon Nov 17 10:04:50 2025 +0000 v2.2.0 commit 347eac1 Author: KavithaSiva <[email protected]> Date: Fri Nov 14 13:01:39 2025 +0100 feat: Embedding client for orchestration (#1135) commit 3e4bf3d Author: David Knaack <[email protected]> Date: Wed Nov 12 13:42:27 2025 +0100 fix: Use trusted publishing for the canary workflow (#1272) * fix: Use trusted publishing for the canary workflow * fix: Add tag input to changeset publish command in canary workflow * chore: revert job split * fix: bump node.js for trusted publishing commit a86f855 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed Nov 12 00:30:37 2025 +0000 chore(deps): Bump @sap/xssec from 4.11.1 to 4.11.2 (#1275) Bumps @sap/xssec from 4.11.1 to 4.11.2. --- updated-dependencies: - dependency-name: "@sap/xssec" dependency-version: 4.11.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit d0cb667 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed Nov 12 00:30:15 2025 +0000 chore(deps-dev): Bump @types/node from 22.19.0 to 22.19.1 (#1273) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.19.0 to 22.19.1. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-version: 22.19.1 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit e2c34f3 Author: David Knaack <[email protected]> Date: Tue Nov 11 11:32:24 2025 +0100 feat: Update document-grounding specification (#1269) * Update document-grounding based on main * Update document-grounding based on main * Update document-grounding based on main * chore: add changeset * chore: split up changeset --------- Co-authored-by: SAP Cloud SDK Bot <[email protected]> commit 4c4d283 Author: BrigittaK307 <[email protected]> Date: Mon Nov 10 14:40:00 2025 +0200 chore: Update to new orchestration release (#1262) * Update to new orchestration release * Ran postgenerate script adapted to windows * Minor changes * Reverted translation.ts and targetLanguage * fix: Changes from lint * Solved failing test case * Removed applyTo selector * Apply suggestion from @ZhongpinWang * Apply suggestion from @ZhongpinWang --------- Co-authored-by: Zhongpin Wang <[email protected]> Co-authored-by: cloud-sdk-js <[email protected]> commit 58464e9 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon Nov 10 13:31:17 2025 +0100 feat: Update ai-api specification (#1189) * Update ai-api based on main * Add changeset * Add release version to changeset --------- Co-authored-by: SAP Cloud SDK Bot <[email protected]> Co-authored-by: Zhongpin Wang <[email protected]> commit 6100bca Author: David Knaack <[email protected]> Date: Mon Nov 10 11:17:55 2025 +0100 chore: Update available model list & remove compatibility handling (#1264) * chore: Update available model list * chore: Remove deprecated `withStructuredOutput`-handling in langchain/openai * chore: fix typo Co-authored-by: Zhongpin Wang <[email protected]> * Apply suggestion from @ZhongpinWang --------- Co-authored-by: Zhongpin Wang <[email protected]> commit 49d1a44 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Nov 10 00:38:42 2025 +0000 chore(deps): Bump @modelcontextprotocol/sdk from 1.20.2 to 1.21.1 (#1268) Bumps [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk) from 1.20.2 to 1.21.1. - [Release notes](https://github.com/modelcontextprotocol/typescript-sdk/releases) - [Commits](modelcontextprotocol/typescript-sdk@1.20.2...1.21.1) --- updated-dependencies: - dependency-name: "@modelcontextprotocol/sdk" dependency-version: 1.21.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit f692377 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon Nov 10 00:38:15 2025 +0000 chore(deps): Bump @sap/xssec from 4.11.0 to 4.11.1 (#1265) Bumps @sap/xssec from 4.11.0 to 4.11.1. --- updated-dependencies: - dependency-name: "@sap/xssec" dependency-version: 4.11.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: re-bump mcp sdk * chore: Migrate from `strict` to `strictObject` * chore: allow major langchain updates to `main` again, but group future updates --------- Co-authored-by: deeksha sinha <[email protected]> Co-authored-by: Deeksha Sinha <[email protected]> Co-authored-by: Zhongpin Wang <[email protected]>
1 parent 2b4802b commit 7c9605d

File tree

22 files changed

+601
-535
lines changed

22 files changed

+601
-535
lines changed

.changeset/clean-dolls-tap.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@sap-ai-sdk/prompt-registry': minor
3+
'@sap-ai-sdk/orchestration': minor
4+
'@sap-ai-sdk/langchain': minor
5+
---
6+
7+
[Compatibility Note] `zod` was upgraded to v4

.changeset/crisp-animals-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sap-ai-sdk/langchain': minor
3+
---
4+
5+
[feat] Bump langchain to v1

.github/dependabot.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ updates:
1212
# We only want to do major node updates on purpose, so don't create dependabot PRs for major versions
1313
- dependency-name: '@types/node'
1414
update-types: ['version-update:semver-major']
15-
# Skip v1-release until compability is handled throughout the project
16-
- dependency-name: 'langchain'
17-
update-types: ['version-update:semver-major']
18-
- dependency-name: '@langchain/*'
19-
update-types: ['version-update:semver-major']
2015
groups:
2116
sap-cloud-sdk:
2217
patterns: ['@sap-cloud-sdk/*']
18+
langchain:
19+
patterns: ['langchain', '@langchain/*']
2320
- package-ecosystem: npm
2421
directory: '/'
2522
target-branch: 'v1-main'

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@
3333
"check:deps": "pnpm -r -F !./tests/smoke-tests -F !./sample-cap exec depcheck --ignores=\"nock,@jest/globals\" --quiet"
3434
},
3535
"devDependencies": {
36-
"orval": "^7.17.0",
37-
"zod": "^3.25.76",
3836
"@changesets/cli": "^2.29.7",
3937
"@jest/globals": "^30.2.0",
4038
"@sap-ai-sdk/ai-api": "workspace:^",
4139
"@sap-ai-sdk/core": "workspace:^",
4240
"@sap-ai-sdk/foundation-models": "workspace:^",
4341
"@sap-ai-sdk/orchestration": "workspace:^",
44-
"tsx": "^4.20.6",
4542
"@sap-cloud-sdk/connectivity": "^4.1.2",
4643
"@sap-cloud-sdk/eslint-config": "^4.1.2",
4744
"@sap-cloud-sdk/generator-common": "^4.1.2",
@@ -59,9 +56,12 @@
5956
"jsonwebtoken": "^9.0.2",
6057
"mock-fs": "^5.5.0",
6158
"nock": "^14.0.10",
59+
"orval": "^7.17.0",
6260
"prettier": "^3.6.2",
6361
"ts-jest": "^29.4.5",
6462
"ts-node": "^10.9.2",
65-
"typescript": "^5.9.3"
63+
"tsx": "^4.20.6",
64+
"typescript": "^5.9.3",
65+
"zod": "^4.1.13"
6666
}
6767
}

packages/langchain/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525
],
2626
"scripts": {
2727
"compile": "tsc",
28-
"compile:cjs": "tsc -p tsconfig.cjs.json",
28+
"compile:cjs": "mv package.json package.json.bak && echo '{ \"type\": \"commonjs\" }' > package.json && tsc -p tsconfig.cjs.json && mv package.json.bak package.json",
2929
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
3030
"lint": "eslint \"**/*.ts\" && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -c",
3131
"lint:fix": "eslint \"**/*.ts\" --fix && prettier . --config ../../.prettierrc --ignore-path ../../.prettierignore -w --log-level error"
3232
},
3333
"dependencies": {
34+
"@langchain/core": "^1.0.6",
3435
"@sap-ai-sdk/ai-api": "workspace:^",
3536
"@sap-ai-sdk/core": "workspace:^",
3637
"@sap-ai-sdk/foundation-models": "workspace:^",
3738
"@sap-ai-sdk/orchestration": "workspace:^",
3839
"@sap-cloud-sdk/connectivity": "^4.1.2",
3940
"@sap-cloud-sdk/util": "^4.1.2",
40-
"uuid": "^13.0.0",
41-
"@langchain/core": "0.3.79"
41+
"uuid": "^13.0.0"
4242
}
4343
}

packages/langchain/src/openai/__snapshots__/chat.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ exports[`Chat client streaming supports streaming responses 1`] = `
3030
"tool_call_chunks": [],
3131
"tool_calls": [],
3232
"usage_metadata": {
33+
"input_token_details": {},
3334
"input_tokens": 14,
35+
"output_token_details": {},
3436
"output_tokens": 7,
3537
"total_tokens": 21,
3638
},
@@ -98,7 +100,9 @@ exports[`Chat client streaming supports streaming responses with tool calls 1`]
98100
},
99101
],
100102
"usage_metadata": {
103+
"input_token_details": {},
101104
"input_tokens": 52,
105+
"output_token_details": {},
102106
"output_tokens": 18,
103107
"total_tokens": 70,
104108
},

packages/langchain/src/openai/__snapshots__/util.test.ts.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ exports[`Mapping Functions should parse an OpenAI response to a (LangChain) chat
2525
"invalid_tool_calls": [],
2626
"response_metadata": {},
2727
"tool_calls": [],
28+
"usage_metadata": {
29+
"input_tokens": 0,
30+
"output_tokens": 0,
31+
"total_tokens": 0,
32+
},
2833
},
2934
"lc": 1,
3035
"type": "constructor",

packages/langchain/src/openai/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class AzureOpenAiChatClient extends BaseChatModel<AzureOpenAiChatCallOpti
207207
}
208208
},
209209
ls_structured_output_format: {
210-
kwargs: { method: 'jsonSchema' },
210+
kwargs: { method: 'functionCalling' },
211211
schema: asJsonSchema
212212
}
213213
} as Partial<AzureOpenAiChatCallOptions>);

packages/langchain/src/openai/util.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ export function mapOutputToChatResult(
127127
tool_calls: mapAzureOpenAiToLangChainToolCall(
128128
choice.message.tool_calls
129129
),
130+
usage_metadata: {
131+
input_tokens: choice.message.usage?.prompt_tokens ?? 0,
132+
output_tokens: choice.message.usage?.completion_tokens ?? 0,
133+
total_tokens: choice.message.usage?.total_tokens ?? 0
134+
},
130135
additional_kwargs: {
131136
function_call: choice.message.function_call,
132137
tool_calls: choice.message.tool_calls
@@ -248,19 +253,23 @@ function mapSystemMessageToAzureOpenAiSystemMessage(
248253
function mapBaseMessageToAzureOpenAiChatMessage(
249254
message: BaseMessage
250255
): AzureOpenAiChatCompletionRequestMessage {
251-
switch (message.getType()) {
256+
switch (message.type) {
252257
case 'ai':
253-
return mapAiMessageToAzureOpenAiAssistantMessage(message);
258+
return mapAiMessageToAzureOpenAiAssistantMessage(message as AIMessage);
254259
case 'human':
255-
return mapHumanMessageToAzureOpenAiUserMessage(message);
260+
return mapHumanMessageToAzureOpenAiUserMessage(message as HumanMessage);
256261
case 'system':
257-
return mapSystemMessageToAzureOpenAiSystemMessage(message);
262+
return mapSystemMessageToAzureOpenAiSystemMessage(
263+
message as SystemMessage
264+
);
258265
case 'function':
259-
return mapFunctionMessageToAzureOpenAiFunctionMessage(message);
266+
return mapFunctionMessageToAzureOpenAiFunctionMessage(
267+
message as FunctionMessage
268+
);
260269
case 'tool':
261270
return mapToolMessageToAzureOpenAiToolMessage(message as ToolMessage);
262271
default:
263-
throw new Error(`Unsupported message type: ${message.getType()}`);
272+
throw new Error(`Unsupported message type: ${message.type}`);
264273
}
265274
}
266275

packages/langchain/src/orchestration/__snapshots__/client.test.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ exports[`orchestration service client resilience returns successful response whe
2828
"tool_calls": undefined,
2929
},
3030
"tool_calls": [],
31+
"usage_metadata": {
32+
"input_tokens": 9,
33+
"output_tokens": 10,
34+
"total_tokens": 19,
35+
},
3136
},
3237
"lc": 1,
3338
"type": "constructor",
@@ -62,6 +67,11 @@ exports[`orchestration service client resilience returns successful response whe
6267
"tool_calls": undefined,
6368
},
6469
"tool_calls": [],
70+
"usage_metadata": {
71+
"input_tokens": 9,
72+
"output_tokens": 10,
73+
"total_tokens": 19,
74+
},
6575
},
6676
"lc": 1,
6777
"type": "constructor",
@@ -157,7 +167,9 @@ Overall, the SAP Cloud SDK is an essential tool for developers looking to build
157167
"tool_call_chunks": [],
158168
"tool_calls": [],
159169
"usage_metadata": {
170+
"input_token_details": {},
160171
"input_tokens": 17,
172+
"output_token_details": {},
161173
"output_tokens": 271,
162174
"total_tokens": 288,
163175
},

0 commit comments

Comments
 (0)