@ai-sdk/anthropic 3.0.77 → 3.0.78
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/CHANGELOG.md +6 -0
- package/dist/index.js +25 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -19
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +24 -18
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +24 -18
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/convert-to-anthropic-messages-prompt.ts +16 -3
package/package.json
CHANGED
|
@@ -281,9 +281,19 @@ export async function convertToAnthropicMessagesPrompt({
|
|
|
281
281
|
continue;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
const output = part.output;
|
|
285
|
+
const outputProviderOptions =
|
|
286
|
+
'providerOptions' in output
|
|
287
|
+
? output.providerOptions
|
|
288
|
+
: output.type === 'content'
|
|
289
|
+
? output.value.find(
|
|
290
|
+
contentPart => contentPart.providerOptions != null,
|
|
291
|
+
)?.providerOptions
|
|
292
|
+
: undefined;
|
|
293
|
+
|
|
284
294
|
// cache control: first add cache control from part.
|
|
285
|
-
// for the last part of a
|
|
286
|
-
// check also if the message has cache control.
|
|
295
|
+
// then from tool result output, and for the last part of a
|
|
296
|
+
// message, check also if the message has cache control.
|
|
287
297
|
const isLastPart = i === content.length - 1;
|
|
288
298
|
|
|
289
299
|
const cacheControl =
|
|
@@ -291,6 +301,10 @@ export async function convertToAnthropicMessagesPrompt({
|
|
|
291
301
|
type: 'tool result part',
|
|
292
302
|
canCache: true,
|
|
293
303
|
}) ??
|
|
304
|
+
validator.getCacheControl(outputProviderOptions, {
|
|
305
|
+
type: 'tool result output',
|
|
306
|
+
canCache: true,
|
|
307
|
+
}) ??
|
|
294
308
|
(isLastPart
|
|
295
309
|
? validator.getCacheControl(message.providerOptions, {
|
|
296
310
|
type: 'tool result message',
|
|
@@ -298,7 +312,6 @@ export async function convertToAnthropicMessagesPrompt({
|
|
|
298
312
|
})
|
|
299
313
|
: undefined);
|
|
300
314
|
|
|
301
|
-
const output = part.output;
|
|
302
315
|
let contentValue: AnthropicToolResultContent['content'];
|
|
303
316
|
switch (output.type) {
|
|
304
317
|
case 'content':
|