@ai-sdk/amazon-bedrock
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -328,5 +328,3 @@ "use strict"; | ||
}); | ||
let toolName = ""; | ||
let toolCallId = ""; | ||
let toolCallArgs = ""; | ||
const toolCallContentBlocks = {}; | ||
return { | ||
@@ -336,3 +334,3 @@ stream: stream.pipeThrough( | ||
transform(chunk, controller) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i; | ||
function enqueueError(error) { | ||
@@ -387,25 +385,38 @@ finishReason = "error"; | ||
} | ||
if ((_h = (_g = value.contentBlockStart) == null ? void 0 : _g.start) == null ? void 0 : _h.toolUse) { | ||
const toolUse = value.contentBlockStart.start.toolUse; | ||
toolName = (_i = toolUse.name) != null ? _i : ""; | ||
toolCallId = (_j = toolUse.toolUseId) != null ? _j : ""; | ||
const contentBlockStart = value.contentBlockStart; | ||
if (((_g = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _g.toolUse) != null) { | ||
const toolUse = contentBlockStart.start.toolUse; | ||
toolCallContentBlocks[contentBlockStart.contentBlockIndex] = { | ||
toolCallId: toolUse.toolUseId, | ||
toolName: toolUse.name, | ||
jsonText: "" | ||
}; | ||
} | ||
if ((_l = (_k = value.contentBlockDelta) == null ? void 0 : _k.delta) == null ? void 0 : _l.toolUse) { | ||
toolCallArgs += (_m = value.contentBlockDelta.delta.toolUse.input) != null ? _m : ""; | ||
const contentBlockDelta = value.contentBlockDelta; | ||
if ((_h = contentBlockDelta == null ? void 0 : contentBlockDelta.delta) == null ? void 0 : _h.toolUse) { | ||
const contentBlock = toolCallContentBlocks[contentBlockDelta.contentBlockIndex]; | ||
const delta = (_i = contentBlockDelta.delta.toolUse.input) != null ? _i : ""; | ||
controller.enqueue({ | ||
type: "tool-call-delta", | ||
toolCallType: "function", | ||
toolCallId, | ||
toolName, | ||
argsTextDelta: (_n = value.contentBlockDelta.delta.toolUse.input) != null ? _n : "" | ||
toolCallId: contentBlock.toolCallId, | ||
toolName: contentBlock.toolName, | ||
argsTextDelta: delta | ||
}); | ||
contentBlock.jsonText += delta; | ||
} | ||
if (value.contentBlockStop && toolCallArgs.length > 0) { | ||
controller.enqueue({ | ||
type: "tool-call", | ||
toolCallType: "function", | ||
toolCallId, | ||
toolName, | ||
args: toolCallArgs | ||
}); | ||
const contentBlockStop = value.contentBlockStop; | ||
if (contentBlockStop != null) { | ||
const index = contentBlockStop.contentBlockIndex; | ||
const contentBlock = toolCallContentBlocks[index]; | ||
if (contentBlock != null) { | ||
controller.enqueue({ | ||
type: "tool-call", | ||
toolCallType: "function", | ||
toolCallId: contentBlock.toolCallId, | ||
toolName: contentBlock.toolName, | ||
args: contentBlock.jsonText | ||
}); | ||
delete toolCallContentBlocks[index]; | ||
} | ||
} | ||
@@ -412,0 +423,0 @@ }, |
# @ai-sdk/amazon-bedrock | ||
## 0.0.26 | ||
### Patch Changes | ||
- 8f080f4: fix (provider/bedrock): support parallel tool calls in streaming mode | ||
## 0.0.25 | ||
@@ -4,0 +10,0 @@ |
@@ -328,5 +328,3 @@ "use strict"; | ||
}); | ||
let toolName = ""; | ||
let toolCallId = ""; | ||
let toolCallArgs = ""; | ||
const toolCallContentBlocks = {}; | ||
return { | ||
@@ -336,3 +334,3 @@ stream: stream.pipeThrough( | ||
transform(chunk, controller) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i; | ||
function enqueueError(error) { | ||
@@ -387,25 +385,38 @@ finishReason = "error"; | ||
} | ||
if ((_h = (_g = value.contentBlockStart) == null ? void 0 : _g.start) == null ? void 0 : _h.toolUse) { | ||
const toolUse = value.contentBlockStart.start.toolUse; | ||
toolName = (_i = toolUse.name) != null ? _i : ""; | ||
toolCallId = (_j = toolUse.toolUseId) != null ? _j : ""; | ||
const contentBlockStart = value.contentBlockStart; | ||
if (((_g = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _g.toolUse) != null) { | ||
const toolUse = contentBlockStart.start.toolUse; | ||
toolCallContentBlocks[contentBlockStart.contentBlockIndex] = { | ||
toolCallId: toolUse.toolUseId, | ||
toolName: toolUse.name, | ||
jsonText: "" | ||
}; | ||
} | ||
if ((_l = (_k = value.contentBlockDelta) == null ? void 0 : _k.delta) == null ? void 0 : _l.toolUse) { | ||
toolCallArgs += (_m = value.contentBlockDelta.delta.toolUse.input) != null ? _m : ""; | ||
const contentBlockDelta = value.contentBlockDelta; | ||
if ((_h = contentBlockDelta == null ? void 0 : contentBlockDelta.delta) == null ? void 0 : _h.toolUse) { | ||
const contentBlock = toolCallContentBlocks[contentBlockDelta.contentBlockIndex]; | ||
const delta = (_i = contentBlockDelta.delta.toolUse.input) != null ? _i : ""; | ||
controller.enqueue({ | ||
type: "tool-call-delta", | ||
toolCallType: "function", | ||
toolCallId, | ||
toolName, | ||
argsTextDelta: (_n = value.contentBlockDelta.delta.toolUse.input) != null ? _n : "" | ||
toolCallId: contentBlock.toolCallId, | ||
toolName: contentBlock.toolName, | ||
argsTextDelta: delta | ||
}); | ||
contentBlock.jsonText += delta; | ||
} | ||
if (value.contentBlockStop && toolCallArgs.length > 0) { | ||
controller.enqueue({ | ||
type: "tool-call", | ||
toolCallType: "function", | ||
toolCallId, | ||
toolName, | ||
args: toolCallArgs | ||
}); | ||
const contentBlockStop = value.contentBlockStop; | ||
if (contentBlockStop != null) { | ||
const index = contentBlockStop.contentBlockIndex; | ||
const contentBlock = toolCallContentBlocks[index]; | ||
if (contentBlock != null) { | ||
controller.enqueue({ | ||
type: "tool-call", | ||
toolCallType: "function", | ||
toolCallId: contentBlock.toolCallId, | ||
toolName: contentBlock.toolName, | ||
args: contentBlock.jsonText | ||
}); | ||
delete toolCallContentBlocks[index]; | ||
} | ||
} | ||
@@ -412,0 +423,0 @@ }, |
{ | ||
"name": "@ai-sdk/amazon-bedrock", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -1,4 +0,4 @@ | ||
# Vercel AI SDK - Amazon Bedrock Provider | ||
# AI SDK - Amazon Bedrock Provider | ||
The **[Amazon Bedrock provider](https://sdk.vercel.ai/providers/ai-sdk-providers/amazon-bedrock)** for the [Vercel AI SDK](https://sdk.vercel.ai/docs) | ||
The **[Amazon Bedrock provider](https://sdk.vercel.ai/providers/ai-sdk-providers/amazon-bedrock)** for the [AI SDK](https://sdk.vercel.ai/docs) | ||
contains language model support for the Amazon Bedrock [converse API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html). | ||
@@ -5,0 +5,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124018
1600