@fairyhunter13/ai-anthropic 3.0.74-fork.0 → 3.0.74-fork.2

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 4.0.0-canary.44
4
+
5
+ ### Patch Changes
6
+
7
+ - 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
8
+ - Updated dependencies [5463d0d]
9
+ - @ai-sdk/provider-utils@5.0.0-canary.32
10
+ - @ai-sdk/provider@4.0.0-canary.16
11
+
3
12
  ## 4.0.0-canary.43
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2500,49 +2500,65 @@ async function convertToAnthropicPrompt({
2500
2500
  type: "text",
2501
2501
  text: contentPart.text
2502
2502
  };
2503
- case "file-url": {
2504
- if (contentPart.mediaType.startsWith("image/")) {
2503
+ case "file": {
2504
+ const topLevel = getTopLevelMediaType(
2505
+ contentPart.mediaType
2506
+ );
2507
+ if (contentPart.data.type === "url") {
2508
+ if (topLevel === "image") {
2509
+ return {
2510
+ type: "image",
2511
+ source: {
2512
+ type: "url",
2513
+ url: contentPart.data.url.toString()
2514
+ }
2515
+ };
2516
+ }
2505
2517
  return {
2506
- type: "image",
2518
+ type: "document",
2507
2519
  source: {
2508
2520
  type: "url",
2509
- url: contentPart.url
2521
+ url: contentPart.data.url.toString()
2510
2522
  }
2511
2523
  };
2512
2524
  }
2513
- return {
2514
- type: "document",
2515
- source: {
2516
- type: "url",
2517
- url: contentPart.url
2525
+ if (contentPart.data.type === "data") {
2526
+ if (topLevel === "image") {
2527
+ return {
2528
+ type: "image",
2529
+ source: {
2530
+ type: "base64",
2531
+ media_type: resolveFullMediaType({
2532
+ part: contentPart
2533
+ }),
2534
+ data: convertToBase64(
2535
+ contentPart.data.data
2536
+ )
2537
+ }
2538
+ };
2518
2539
  }
2519
- };
2520
- }
2521
- case "file-data": {
2522
- if (contentPart.mediaType.startsWith("image/")) {
2523
- return {
2524
- type: "image",
2525
- source: {
2526
- type: "base64",
2527
- media_type: contentPart.mediaType,
2528
- data: contentPart.data
2529
- }
2530
- };
2531
- }
2532
- if (contentPart.mediaType === "application/pdf") {
2533
- betas.add("pdfs-2024-09-25");
2534
- return {
2535
- type: "document",
2536
- source: {
2537
- type: "base64",
2538
- media_type: contentPart.mediaType,
2539
- data: contentPart.data
2540
- }
2541
- };
2540
+ if (resolveFullMediaType({ part: contentPart }) === "application/pdf") {
2541
+ betas.add("pdfs-2024-09-25");
2542
+ return {
2543
+ type: "document",
2544
+ source: {
2545
+ type: "base64",
2546
+ media_type: "application/pdf",
2547
+ data: convertToBase64(
2548
+ contentPart.data.data
2549
+ )
2550
+ }
2551
+ };
2552
+ }
2553
+ warnings.push({
2554
+ type: "other",
2555
+ message: `unsupported tool content part type: ${contentPart.type} with media type: ${contentPart.mediaType}`
2556
+ });
2557
+ return void 0;
2542
2558
  }
2543
2559
  warnings.push({
2544
2560
  type: "other",
2545
- message: `unsupported tool content part type: ${contentPart.type} with media type: ${contentPart.mediaType}`
2561
+ message: `unsupported tool content part type: ${contentPart.type} with data type: ${contentPart.data.type}`
2546
2562
  });
2547
2563
  return void 0;
2548
2564
  }
@@ -5928,7 +5944,7 @@ var AnthropicSkills = class {
5928
5944
  };
5929
5945
 
5930
5946
  // src/version.ts
5931
- var VERSION = true ? "4.0.0-canary.43" : "0.0.0-test";
5947
+ var VERSION = true ? "4.0.0-canary.44" : "0.0.0-test";
5932
5948
 
5933
5949
  // src/anthropic-provider.ts
5934
5950
  function createAnthropic(options = {}) {