@librechat/agents 3.1.34 → 3.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/llm/bedrock/index.cjs +115 -55
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +465 -0
- package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -0
- package/dist/cjs/llm/bedrock/utils/message_outputs.cjs +155 -0
- package/dist/cjs/llm/bedrock/utils/message_outputs.cjs.map +1 -0
- package/dist/cjs/messages/core.cjs +3 -0
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +114 -54
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs +460 -0
- package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -0
- package/dist/esm/llm/bedrock/utils/message_outputs.mjs +150 -0
- package/dist/esm/llm/bedrock/utils/message_outputs.mjs.map +1 -0
- package/dist/esm/messages/core.mjs +3 -0
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/types/llm/bedrock/index.d.ts +29 -21
- package/package.json +1 -1
- package/src/llm/bedrock/index.ts +147 -65
- package/src/llm/bedrock/llm.spec.ts +86 -11
- package/src/messages/core.ts +5 -0
- package/src/scripts/bedrock-merge-test.ts +107 -0
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var aws = require('@langchain/aws');
|
|
4
|
+
var clientBedrockRuntime = require('@aws-sdk/client-bedrock-runtime');
|
|
4
5
|
var messages = require('@langchain/core/messages');
|
|
5
6
|
var outputs = require('@langchain/core/outputs');
|
|
7
|
+
var message_inputs = require('./utils/message_inputs.cjs');
|
|
8
|
+
var message_outputs = require('./utils/message_outputs.cjs');
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
|
-
* Optimized ChatBedrockConverse wrapper that fixes
|
|
9
|
-
* and adds support for latest @langchain/aws features:
|
|
11
|
+
* Optimized ChatBedrockConverse wrapper that fixes content block merging for
|
|
12
|
+
* streaming responses and adds support for latest @langchain/aws features:
|
|
10
13
|
*
|
|
11
14
|
* - Application Inference Profiles (PR #9129)
|
|
12
15
|
* - Service Tiers (Priority/Standard/Flex) (PR #9785) - requires AWS SDK 3.966.0+
|
|
13
16
|
*
|
|
14
|
-
* Bedrock
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* the conflict.
|
|
17
|
+
* Bedrock's `@langchain/aws` library does not include an `index` property on content
|
|
18
|
+
* blocks (unlike Anthropic/OpenAI), which causes LangChain's `_mergeLists` to append
|
|
19
|
+
* each streaming chunk as a separate array entry instead of merging by index.
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* This wrapper takes full ownership of the stream by directly interfacing with the
|
|
22
|
+
* AWS SDK client (`this.client`) and using custom handlers from `./utils/` that
|
|
23
|
+
* include `contentBlockIndex` in response_metadata for every delta type. It then
|
|
24
|
+
* promotes `contentBlockIndex` to an `index` property on each content block
|
|
25
|
+
* (mirroring Anthropic's pattern) and strips it from metadata to avoid
|
|
26
|
+
* `_mergeDicts` conflicts.
|
|
27
|
+
*
|
|
28
|
+
* When multiple content block types are present (e.g. reasoning + text), text deltas
|
|
29
|
+
* are promoted from strings to array form with `index` so they merge correctly once
|
|
30
|
+
* the accumulated content is already an array.
|
|
22
31
|
*/
|
|
23
32
|
class CustomChatBedrockConverse extends aws.ChatBedrockConverse {
|
|
24
33
|
/**
|
|
@@ -61,7 +70,6 @@ class CustomChatBedrockConverse extends aws.ChatBedrockConverse {
|
|
|
61
70
|
* Uses the same model-swapping pattern as streaming for consistency.
|
|
62
71
|
*/
|
|
63
72
|
async _generateNonStreaming(messages, options, runManager) {
|
|
64
|
-
// Temporarily swap model for applicationInferenceProfile support
|
|
65
73
|
const originalModel = this.model;
|
|
66
74
|
if (this.applicationInferenceProfile != null &&
|
|
67
75
|
this.applicationInferenceProfile !== '') {
|
|
@@ -71,83 +79,135 @@ class CustomChatBedrockConverse extends aws.ChatBedrockConverse {
|
|
|
71
79
|
return await super._generateNonStreaming(messages, options, runManager);
|
|
72
80
|
}
|
|
73
81
|
finally {
|
|
74
|
-
// Restore original model
|
|
75
82
|
this.model = originalModel;
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* 2. Strip contentBlockIndex from response_metadata to prevent merge conflicts
|
|
86
|
+
* Own the stream end-to-end so we have direct access to every
|
|
87
|
+
* `contentBlockDelta.contentBlockIndex` from the AWS SDK.
|
|
82
88
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
89
|
+
* This replaces the parent's implementation which strips contentBlockIndex
|
|
90
|
+
* from text and reasoning deltas, making it impossible to merge correctly.
|
|
85
91
|
*/
|
|
86
|
-
async *_streamResponseChunks(messages, options, runManager) {
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
async *_streamResponseChunks(messages$1, options, runManager) {
|
|
93
|
+
const { converseMessages, converseSystem } = message_inputs.convertToConverseMessages(messages$1);
|
|
94
|
+
const params = this.invocationParams(options);
|
|
95
|
+
let { streamUsage } = this;
|
|
96
|
+
if (options.streamUsage !== undefined) {
|
|
97
|
+
streamUsage = options.streamUsage;
|
|
92
98
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
const modelId = this.getModelId();
|
|
100
|
+
const command = new clientBedrockRuntime.ConverseStreamCommand({
|
|
101
|
+
modelId,
|
|
102
|
+
messages: converseMessages,
|
|
103
|
+
system: converseSystem,
|
|
104
|
+
...params,
|
|
105
|
+
});
|
|
106
|
+
const response = await this.client.send(command, {
|
|
107
|
+
abortSignal: options.signal,
|
|
108
|
+
});
|
|
109
|
+
if (!response.stream) {
|
|
110
|
+
return;
|
|
100
111
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
112
|
+
const seenBlockIndices = new Set();
|
|
113
|
+
for await (const event of response.stream) {
|
|
114
|
+
if (event.contentBlockStart != null) {
|
|
115
|
+
const startChunk = message_outputs.handleConverseStreamContentBlockStart(event.contentBlockStart);
|
|
116
|
+
if (startChunk != null) {
|
|
117
|
+
const idx = event.contentBlockStart.contentBlockIndex;
|
|
118
|
+
if (idx != null) {
|
|
119
|
+
seenBlockIndices.add(idx);
|
|
120
|
+
}
|
|
121
|
+
yield this.enrichChunk(startChunk, seenBlockIndices);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (event.contentBlockDelta != null) {
|
|
125
|
+
const deltaChunk = message_outputs.handleConverseStreamContentBlockDelta(event.contentBlockDelta);
|
|
126
|
+
const idx = event.contentBlockDelta.contentBlockIndex;
|
|
127
|
+
if (idx != null) {
|
|
128
|
+
seenBlockIndices.add(idx);
|
|
129
|
+
}
|
|
130
|
+
yield this.enrichChunk(deltaChunk, seenBlockIndices);
|
|
131
|
+
await runManager?.handleLLMNewToken(deltaChunk.text, undefined, undefined, undefined, undefined, { chunk: deltaChunk });
|
|
132
|
+
}
|
|
133
|
+
else if (event.metadata != null) {
|
|
134
|
+
yield message_outputs.handleConverseStreamMetadata(event.metadata, { streamUsage });
|
|
135
|
+
}
|
|
136
|
+
else if (event.contentBlockStop != null) {
|
|
137
|
+
const stopIdx = event.contentBlockStop.contentBlockIndex;
|
|
138
|
+
if (stopIdx != null) {
|
|
139
|
+
seenBlockIndices.add(stopIdx);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
yield new outputs.ChatGenerationChunk({
|
|
144
|
+
text: '',
|
|
145
|
+
message: new messages.AIMessageChunk({
|
|
146
|
+
content: '',
|
|
147
|
+
response_metadata: event,
|
|
148
|
+
}),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
104
151
|
}
|
|
105
152
|
}
|
|
106
153
|
/**
|
|
107
|
-
*
|
|
154
|
+
* Inject `index` on content blocks for proper merge behaviour, then strip
|
|
155
|
+
* `contentBlockIndex` from response_metadata to prevent `_mergeDicts` conflicts.
|
|
156
|
+
*
|
|
157
|
+
* Text string content is promoted to array form only when the stream contains
|
|
158
|
+
* multiple content block indices (e.g. reasoning at index 0, text at index 1),
|
|
159
|
+
* ensuring text merges correctly with the already-array accumulated content.
|
|
108
160
|
*/
|
|
109
|
-
|
|
161
|
+
enrichChunk(chunk, seenBlockIndices) {
|
|
110
162
|
const message = chunk.message;
|
|
111
163
|
if (!(message instanceof messages.AIMessageChunk)) {
|
|
112
164
|
return chunk;
|
|
113
165
|
}
|
|
114
166
|
const metadata = message.response_metadata;
|
|
115
|
-
const
|
|
116
|
-
|
|
167
|
+
const blockIndex = this.extractContentBlockIndex(metadata);
|
|
168
|
+
const hasMetadataIndex = blockIndex != null;
|
|
169
|
+
let content = message.content;
|
|
170
|
+
let contentModified = false;
|
|
171
|
+
if (Array.isArray(content) && blockIndex != null) {
|
|
172
|
+
content = content.map((block) => typeof block === 'object' && !('index' in block)
|
|
173
|
+
? { ...block, index: blockIndex }
|
|
174
|
+
: block);
|
|
175
|
+
contentModified = true;
|
|
176
|
+
}
|
|
177
|
+
else if (typeof content === 'string' &&
|
|
178
|
+
content !== '' &&
|
|
179
|
+
blockIndex != null &&
|
|
180
|
+
seenBlockIndices.size > 1) {
|
|
181
|
+
content = [{ type: 'text', text: content, index: blockIndex }];
|
|
182
|
+
contentModified = true;
|
|
183
|
+
}
|
|
184
|
+
if (!contentModified && !hasMetadataIndex) {
|
|
117
185
|
return chunk;
|
|
118
186
|
}
|
|
119
|
-
const cleanedMetadata =
|
|
187
|
+
const cleanedMetadata = hasMetadataIndex
|
|
188
|
+
? this.removeContentBlockIndex(metadata)
|
|
189
|
+
: metadata;
|
|
120
190
|
return new outputs.ChatGenerationChunk({
|
|
121
191
|
text: chunk.text,
|
|
122
192
|
message: new messages.AIMessageChunk({
|
|
123
193
|
...message,
|
|
194
|
+
content,
|
|
124
195
|
response_metadata: cleanedMetadata,
|
|
125
196
|
}),
|
|
126
197
|
generationInfo: chunk.generationInfo,
|
|
127
198
|
});
|
|
128
199
|
}
|
|
129
200
|
/**
|
|
130
|
-
*
|
|
201
|
+
* Extract `contentBlockIndex` from the top level of response_metadata.
|
|
202
|
+
* Our custom handlers always place it at the top level.
|
|
131
203
|
*/
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if ('contentBlockIndex' in obj) {
|
|
137
|
-
return true;
|
|
204
|
+
extractContentBlockIndex(metadata) {
|
|
205
|
+
if ('contentBlockIndex' in metadata &&
|
|
206
|
+
typeof metadata.contentBlockIndex === 'number') {
|
|
207
|
+
return metadata.contentBlockIndex;
|
|
138
208
|
}
|
|
139
|
-
|
|
140
|
-
if (typeof value === 'object' && value !== null) {
|
|
141
|
-
if (this.hasContentBlockIndex(value)) {
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
209
|
+
return undefined;
|
|
147
210
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Recursively remove contentBlockIndex from all levels of an object
|
|
150
|
-
*/
|
|
151
211
|
removeContentBlockIndex(obj) {
|
|
152
212
|
if (obj === null || obj === undefined) {
|
|
153
213
|
return obj;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/llm/bedrock/index.ts"],"sourcesContent":["/**\n * Optimized ChatBedrockConverse wrapper that fixes contentBlockIndex conflicts\n * and adds support for latest @langchain/aws features:\n *\n * - Application Inference Profiles (PR #9129)\n * - Service Tiers (Priority/Standard/Flex) (PR #9785) - requires AWS SDK 3.966.0+\n *\n * Bedrock sends the same contentBlockIndex for both text and tool_use content blocks,\n * causing LangChain's merge logic to fail with \"field[contentBlockIndex] already exists\"\n * errors. This wrapper simply strips contentBlockIndex from response_metadata to avoid\n * the conflict.\n *\n * The contentBlockIndex field is only used internally by Bedrock's streaming protocol\n * and isn't needed by application logic - the index field on tool_call_chunks serves\n * the purpose of tracking tool call ordering.\n */\n\nimport { ChatBedrockConverse } from '@langchain/aws';\nimport { AIMessageChunk } from '@langchain/core/messages';\nimport { ChatGenerationChunk, ChatResult } from '@langchain/core/outputs';\nimport type { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';\nimport type { ChatBedrockConverseInput } from '@langchain/aws';\nimport type { BaseMessage } from '@langchain/core/messages';\n\n/**\n * Service tier type for Bedrock invocations.\n * Requires AWS SDK >= 3.966.0 to actually work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\nexport type ServiceTierType = 'priority' | 'default' | 'flex' | 'reserved';\n\n/**\n * Extended input interface with additional features:\n * - applicationInferenceProfile: Use an inference profile ARN instead of model ID\n * - serviceTier: Specify service tier (Priority, Standard, Flex, Reserved)\n */\nexport interface CustomChatBedrockConverseInput\n extends ChatBedrockConverseInput {\n /**\n * Application Inference Profile ARN to use for the model.\n * For example, \"arn:aws:bedrock:eu-west-1:123456789102:application-inference-profile/fm16bt65tzgx\"\n * When provided, this ARN will be used for the actual inference calls instead of the model ID.\n * Must still provide `model` as normal modelId to benefit from all the metadata.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-create.html\n */\n applicationInferenceProfile?: string;\n\n /**\n * Service tier for model invocation.\n * Specifies the processing tier type used for serving the request.\n * Supported values are 'priority', 'default', 'flex', and 'reserved'.\n *\n * - 'priority': Prioritized processing for lower latency\n * - 'default': Standard processing tier\n * - 'flex': Flexible processing tier with lower cost\n * - 'reserved': Reserved capacity for consistent performance\n *\n * If not provided, AWS uses the default tier.\n * Note: Requires AWS SDK >= 3.966.0 to work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\n serviceTier?: ServiceTierType;\n}\n\n/**\n * Extended call options with serviceTier override support.\n */\nexport interface CustomChatBedrockConverseCallOptions {\n serviceTier?: ServiceTierType;\n}\n\nexport class CustomChatBedrockConverse extends ChatBedrockConverse {\n /**\n * Application Inference Profile ARN to use instead of model ID.\n */\n applicationInferenceProfile?: string;\n\n /**\n * Service tier for model invocation.\n */\n serviceTier?: ServiceTierType;\n\n constructor(fields?: CustomChatBedrockConverseInput) {\n super(fields);\n this.applicationInferenceProfile = fields?.applicationInferenceProfile;\n this.serviceTier = fields?.serviceTier;\n }\n\n static lc_name(): string {\n return 'LibreChatBedrockConverse';\n }\n\n /**\n * Get the model ID to use for API calls.\n * Returns applicationInferenceProfile if set, otherwise returns this.model.\n */\n protected getModelId(): string {\n return this.applicationInferenceProfile ?? this.model;\n }\n\n /**\n * Override invocationParams to add serviceTier support.\n */\n override invocationParams(\n options?: this['ParsedCallOptions'] & CustomChatBedrockConverseCallOptions\n ): ReturnType<ChatBedrockConverse['invocationParams']> & {\n serviceTier?: { type: ServiceTierType };\n } {\n const baseParams = super.invocationParams(options);\n\n /** Service tier from options or fall back to class-level setting */\n const serviceTierType = options?.serviceTier ?? this.serviceTier;\n\n return {\n ...baseParams,\n serviceTier: serviceTierType ? { type: serviceTierType } : undefined,\n };\n }\n\n /**\n * Override _generateNonStreaming to use applicationInferenceProfile as modelId.\n * Uses the same model-swapping pattern as streaming for consistency.\n */\n override async _generateNonStreaming(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & CustomChatBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): Promise<ChatResult> {\n // Temporarily swap model for applicationInferenceProfile support\n const originalModel = this.model;\n if (\n this.applicationInferenceProfile != null &&\n this.applicationInferenceProfile !== ''\n ) {\n this.model = this.applicationInferenceProfile;\n }\n\n try {\n return await super._generateNonStreaming(messages, options, runManager);\n } finally {\n // Restore original model\n this.model = originalModel;\n }\n }\n\n /**\n * Override _streamResponseChunks to:\n * 1. Use applicationInferenceProfile as modelId (by temporarily swapping this.model)\n * 2. Strip contentBlockIndex from response_metadata to prevent merge conflicts\n *\n * Note: We delegate to super._streamResponseChunks() to preserve @langchain/aws's\n * internal chunk handling which correctly preserves array content for reasoning blocks.\n */\n override async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & CustomChatBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n // Temporarily swap model for applicationInferenceProfile support\n const originalModel = this.model;\n if (\n this.applicationInferenceProfile != null &&\n this.applicationInferenceProfile !== ''\n ) {\n this.model = this.applicationInferenceProfile;\n }\n\n try {\n // Use parent's streaming logic which correctly handles reasoning content\n const baseStream = super._streamResponseChunks(\n messages,\n options,\n runManager\n );\n\n for await (const chunk of baseStream) {\n // Clean contentBlockIndex from response_metadata to prevent merge conflicts\n yield this.cleanChunk(chunk);\n }\n } finally {\n // Restore original model\n this.model = originalModel;\n }\n }\n\n /**\n * Clean a chunk by removing contentBlockIndex from response_metadata.\n */\n private cleanChunk(chunk: ChatGenerationChunk): ChatGenerationChunk {\n const message = chunk.message;\n if (!(message instanceof AIMessageChunk)) {\n return chunk;\n }\n\n const metadata = message.response_metadata as Record<string, unknown>;\n const hasContentBlockIndex = this.hasContentBlockIndex(metadata);\n if (!hasContentBlockIndex) {\n return chunk;\n }\n\n const cleanedMetadata = this.removeContentBlockIndex(metadata) as Record<\n string,\n unknown\n >;\n\n return new ChatGenerationChunk({\n text: chunk.text,\n message: new AIMessageChunk({\n ...message,\n response_metadata: cleanedMetadata,\n }),\n generationInfo: chunk.generationInfo,\n });\n }\n\n /**\n * Check if contentBlockIndex exists at any level in the object\n */\n private hasContentBlockIndex(obj: unknown): boolean {\n if (obj === null || obj === undefined || typeof obj !== 'object') {\n return false;\n }\n\n if ('contentBlockIndex' in obj) {\n return true;\n }\n\n for (const value of Object.values(obj)) {\n if (typeof value === 'object' && value !== null) {\n if (this.hasContentBlockIndex(value)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n /**\n * Recursively remove contentBlockIndex from all levels of an object\n */\n private removeContentBlockIndex(obj: unknown): unknown {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => this.removeContentBlockIndex(item));\n }\n\n if (typeof obj === 'object') {\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key !== 'contentBlockIndex') {\n cleaned[key] = this.removeContentBlockIndex(value);\n }\n }\n return cleaned;\n }\n\n return obj;\n }\n}\n\nexport type { ChatBedrockConverseInput };\n"],"names":["ChatBedrockConverse","AIMessageChunk","ChatGenerationChunk"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAwDG,MAAO,yBAA0B,SAAQA,uBAAmB,CAAA;AAChE;;AAEG;AACH,IAAA,2BAA2B;AAE3B;;AAEG;AACH,IAAA,WAAW;AAEX,IAAA,WAAA,CAAY,MAAuC,EAAA;QACjD,KAAK,CAAC,MAAM,CAAC;AACb,QAAA,IAAI,CAAC,2BAA2B,GAAG,MAAM,EAAE,2BAA2B;AACtE,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,EAAE,WAAW;;AAGxC,IAAA,OAAO,OAAO,GAAA;AACZ,QAAA,OAAO,0BAA0B;;AAGnC;;;AAGG;IACO,UAAU,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,2BAA2B,IAAI,IAAI,CAAC,KAAK;;AAGvD;;AAEG;AACM,IAAA,gBAAgB,CACvB,OAA0E,EAAA;QAI1E,MAAM,UAAU,GAAG,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC;;QAGlD,MAAM,eAAe,GAAG,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC,WAAW;QAEhE,OAAO;AACL,YAAA,GAAG,UAAU;AACb,YAAA,WAAW,EAAE,eAAe,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,SAAS;SACrE;;AAGH;;;AAGG;AACM,IAAA,MAAM,qBAAqB,CAClC,QAA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QAAQ,EAAE;YAC3B,MAAM,OAAO,GAA4B,EAAE;AAC3C,YAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAC9C,gBAAA,IAAI,GAAG,KAAK,mBAAmB,EAAE;oBAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC;;;AAGtD,YAAA,OAAO,OAAO;;AAGhB,QAAA,OAAO,GAAG;;AAEb;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/llm/bedrock/index.ts"],"sourcesContent":["/**\n * Optimized ChatBedrockConverse wrapper that fixes content block merging for\n * streaming responses and adds support for latest @langchain/aws features:\n *\n * - Application Inference Profiles (PR #9129)\n * - Service Tiers (Priority/Standard/Flex) (PR #9785) - requires AWS SDK 3.966.0+\n *\n * Bedrock's `@langchain/aws` library does not include an `index` property on content\n * blocks (unlike Anthropic/OpenAI), which causes LangChain's `_mergeLists` to append\n * each streaming chunk as a separate array entry instead of merging by index.\n *\n * This wrapper takes full ownership of the stream by directly interfacing with the\n * AWS SDK client (`this.client`) and using custom handlers from `./utils/` that\n * include `contentBlockIndex` in response_metadata for every delta type. It then\n * promotes `contentBlockIndex` to an `index` property on each content block\n * (mirroring Anthropic's pattern) and strips it from metadata to avoid\n * `_mergeDicts` conflicts.\n *\n * When multiple content block types are present (e.g. reasoning + text), text deltas\n * are promoted from strings to array form with `index` so they merge correctly once\n * the accumulated content is already an array.\n */\n\nimport { ChatBedrockConverse } from '@langchain/aws';\nimport { ConverseStreamCommand } from '@aws-sdk/client-bedrock-runtime';\nimport { AIMessageChunk } from '@langchain/core/messages';\nimport { ChatGenerationChunk, ChatResult } from '@langchain/core/outputs';\nimport type { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';\nimport type { ChatBedrockConverseInput } from '@langchain/aws';\nimport type { BaseMessage } from '@langchain/core/messages';\nimport {\n convertToConverseMessages,\n handleConverseStreamContentBlockStart,\n handleConverseStreamContentBlockDelta,\n handleConverseStreamMetadata,\n} from './utils';\n\n/**\n * Service tier type for Bedrock invocations.\n * Requires AWS SDK >= 3.966.0 to actually work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\nexport type ServiceTierType = 'priority' | 'default' | 'flex' | 'reserved';\n\n/**\n * Extended input interface with additional features:\n * - applicationInferenceProfile: Use an inference profile ARN instead of model ID\n * - serviceTier: Specify service tier (Priority, Standard, Flex, Reserved)\n */\nexport interface CustomChatBedrockConverseInput\n extends ChatBedrockConverseInput {\n /**\n * Application Inference Profile ARN to use for the model.\n * For example, \"arn:aws:bedrock:eu-west-1:123456789102:application-inference-profile/fm16bt65tzgx\"\n * When provided, this ARN will be used for the actual inference calls instead of the model ID.\n * Must still provide `model` as normal modelId to benefit from all the metadata.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-create.html\n */\n applicationInferenceProfile?: string;\n\n /**\n * Service tier for model invocation.\n * Specifies the processing tier type used for serving the request.\n * Supported values are 'priority', 'default', 'flex', and 'reserved'.\n *\n * - 'priority': Prioritized processing for lower latency\n * - 'default': Standard processing tier\n * - 'flex': Flexible processing tier with lower cost\n * - 'reserved': Reserved capacity for consistent performance\n *\n * If not provided, AWS uses the default tier.\n * Note: Requires AWS SDK >= 3.966.0 to work.\n * @see https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html\n */\n serviceTier?: ServiceTierType;\n}\n\n/**\n * Extended call options with serviceTier override support.\n */\nexport interface CustomChatBedrockConverseCallOptions {\n serviceTier?: ServiceTierType;\n}\n\nexport class CustomChatBedrockConverse extends ChatBedrockConverse {\n /**\n * Application Inference Profile ARN to use instead of model ID.\n */\n applicationInferenceProfile?: string;\n\n /**\n * Service tier for model invocation.\n */\n serviceTier?: ServiceTierType;\n\n constructor(fields?: CustomChatBedrockConverseInput) {\n super(fields);\n this.applicationInferenceProfile = fields?.applicationInferenceProfile;\n this.serviceTier = fields?.serviceTier;\n }\n\n static lc_name(): string {\n return 'LibreChatBedrockConverse';\n }\n\n /**\n * Get the model ID to use for API calls.\n * Returns applicationInferenceProfile if set, otherwise returns this.model.\n */\n protected getModelId(): string {\n return this.applicationInferenceProfile ?? this.model;\n }\n\n /**\n * Override invocationParams to add serviceTier support.\n */\n override invocationParams(\n options?: this['ParsedCallOptions'] & CustomChatBedrockConverseCallOptions\n ): ReturnType<ChatBedrockConverse['invocationParams']> & {\n serviceTier?: { type: ServiceTierType };\n } {\n const baseParams = super.invocationParams(options);\n\n /** Service tier from options or fall back to class-level setting */\n const serviceTierType = options?.serviceTier ?? this.serviceTier;\n\n return {\n ...baseParams,\n serviceTier: serviceTierType ? { type: serviceTierType } : undefined,\n };\n }\n\n /**\n * Override _generateNonStreaming to use applicationInferenceProfile as modelId.\n * Uses the same model-swapping pattern as streaming for consistency.\n */\n override async _generateNonStreaming(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & CustomChatBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): Promise<ChatResult> {\n const originalModel = this.model;\n if (\n this.applicationInferenceProfile != null &&\n this.applicationInferenceProfile !== ''\n ) {\n this.model = this.applicationInferenceProfile;\n }\n\n try {\n return await super._generateNonStreaming(messages, options, runManager);\n } finally {\n this.model = originalModel;\n }\n }\n\n /**\n * Own the stream end-to-end so we have direct access to every\n * `contentBlockDelta.contentBlockIndex` from the AWS SDK.\n *\n * This replaces the parent's implementation which strips contentBlockIndex\n * from text and reasoning deltas, making it impossible to merge correctly.\n */\n override async *_streamResponseChunks(\n messages: BaseMessage[],\n options: this['ParsedCallOptions'] & CustomChatBedrockConverseCallOptions,\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n const { converseMessages, converseSystem } =\n convertToConverseMessages(messages);\n const params = this.invocationParams(options);\n\n let { streamUsage } = this;\n if ((options as Record<string, unknown>).streamUsage !== undefined) {\n streamUsage = (options as Record<string, unknown>).streamUsage as boolean;\n }\n\n const modelId = this.getModelId();\n\n const command = new ConverseStreamCommand({\n modelId,\n messages: converseMessages,\n system: converseSystem,\n ...(params as Record<string, unknown>),\n });\n\n const response = await this.client.send(command, {\n abortSignal: options.signal,\n });\n\n if (!response.stream) {\n return;\n }\n\n const seenBlockIndices = new Set<number>();\n\n for await (const event of response.stream) {\n if (event.contentBlockStart != null) {\n const startChunk = handleConverseStreamContentBlockStart(\n event.contentBlockStart\n );\n if (startChunk != null) {\n const idx = event.contentBlockStart.contentBlockIndex;\n if (idx != null) {\n seenBlockIndices.add(idx);\n }\n yield this.enrichChunk(startChunk, seenBlockIndices);\n }\n } else if (event.contentBlockDelta != null) {\n const deltaChunk = handleConverseStreamContentBlockDelta(\n event.contentBlockDelta\n );\n\n const idx = event.contentBlockDelta.contentBlockIndex;\n if (idx != null) {\n seenBlockIndices.add(idx);\n }\n\n yield this.enrichChunk(deltaChunk, seenBlockIndices);\n\n await runManager?.handleLLMNewToken(\n deltaChunk.text,\n undefined,\n undefined,\n undefined,\n undefined,\n { chunk: deltaChunk }\n );\n } else if (event.metadata != null) {\n yield handleConverseStreamMetadata(event.metadata, { streamUsage });\n } else if (event.contentBlockStop != null) {\n const stopIdx = event.contentBlockStop.contentBlockIndex;\n if (stopIdx != null) {\n seenBlockIndices.add(stopIdx);\n }\n } else {\n yield new ChatGenerationChunk({\n text: '',\n message: new AIMessageChunk({\n content: '',\n response_metadata: event,\n }),\n });\n }\n }\n }\n\n /**\n * Inject `index` on content blocks for proper merge behaviour, then strip\n * `contentBlockIndex` from response_metadata to prevent `_mergeDicts` conflicts.\n *\n * Text string content is promoted to array form only when the stream contains\n * multiple content block indices (e.g. reasoning at index 0, text at index 1),\n * ensuring text merges correctly with the already-array accumulated content.\n */\n private enrichChunk(\n chunk: ChatGenerationChunk,\n seenBlockIndices: Set<number>\n ): ChatGenerationChunk {\n const message = chunk.message;\n if (!(message instanceof AIMessageChunk)) {\n return chunk;\n }\n\n const metadata = message.response_metadata as Record<string, unknown>;\n const blockIndex = this.extractContentBlockIndex(metadata);\n const hasMetadataIndex = blockIndex != null;\n\n let content: AIMessageChunk['content'] = message.content;\n let contentModified = false;\n\n if (Array.isArray(content) && blockIndex != null) {\n content = content.map((block) =>\n typeof block === 'object' && !('index' in block)\n ? { ...block, index: blockIndex }\n : block\n );\n contentModified = true;\n } else if (\n typeof content === 'string' &&\n content !== '' &&\n blockIndex != null &&\n seenBlockIndices.size > 1\n ) {\n content = [{ type: 'text', text: content, index: blockIndex }];\n contentModified = true;\n }\n\n if (!contentModified && !hasMetadataIndex) {\n return chunk;\n }\n\n const cleanedMetadata = hasMetadataIndex\n ? (this.removeContentBlockIndex(metadata) as Record<string, unknown>)\n : metadata;\n\n return new ChatGenerationChunk({\n text: chunk.text,\n message: new AIMessageChunk({\n ...message,\n content,\n response_metadata: cleanedMetadata,\n }),\n generationInfo: chunk.generationInfo,\n });\n }\n\n /**\n * Extract `contentBlockIndex` from the top level of response_metadata.\n * Our custom handlers always place it at the top level.\n */\n private extractContentBlockIndex(\n metadata: Record<string, unknown>\n ): number | undefined {\n if (\n 'contentBlockIndex' in metadata &&\n typeof metadata.contentBlockIndex === 'number'\n ) {\n return metadata.contentBlockIndex;\n }\n return undefined;\n }\n\n private removeContentBlockIndex(obj: unknown): unknown {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => this.removeContentBlockIndex(item));\n }\n\n if (typeof obj === 'object') {\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key !== 'contentBlockIndex') {\n cleaned[key] = this.removeContentBlockIndex(value);\n }\n }\n return cleaned;\n }\n\n return obj;\n }\n}\n\nexport type { ChatBedrockConverseInput };\n"],"names":["ChatBedrockConverse","messages","convertToConverseMessages","ConverseStreamCommand","handleConverseStreamContentBlockStart","handleConverseStreamContentBlockDelta","handleConverseStreamMetadata","ChatGenerationChunk","AIMessageChunk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