@ai-sdk__anthropic@3.0.81.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. diff --git a/dist/index.js b/dist/index.js
  2. index f01709ca8909a5724fab4e74a82286af262fbf76..84a19080d0326421e39e2f40df11e69c9fc043ef 100644
  3. --- a/dist/index.js
  4. +++ b/dist/index.js
  5. @@ -2265,6 +2265,19 @@ async function convertToAnthropicMessagesPrompt({
  6. },
  7. cache_control: cacheControl
  8. });
  9. + } else if (part.mediaType.startsWith("video/")) {
  10. + // zcode patch: video/* file part -> video content block (image-block-isomorphic
  11. + // shape used by Anthropic-style compatible gateways; official Anthropic API has
  12. + // no video block yet). Video bytes are serialized as base64.
  13. + anthropicContent.push({
  14. + type: "video",
  15. + source: {
  16. + type: "base64",
  17. + media_type: part.mediaType,
  18. + data: (0, import_provider_utils14.convertToBase64)(part.data)
  19. + },
  20. + cache_control: cacheControl
  21. + });
  22. } else if (part.mediaType === "application/pdf") {
  23. betas.add("pdfs-2024-09-25");
  24. const enableCitations = await shouldEnableCitations(
  25. diff --git a/dist/index.mjs b/dist/index.mjs
  26. index 06a5c9546bc32c59b5aaa4222e7a756a6d22f6d1..fe575cd4100a1b7c2f9ed0769a707633b4a88f10 100644
  27. --- a/dist/index.mjs
  28. +++ b/dist/index.mjs
  29. @@ -2314,6 +2314,19 @@ async function convertToAnthropicMessagesPrompt({
  30. },
  31. cache_control: cacheControl
  32. });
  33. + } else if (part.mediaType.startsWith("video/")) {
  34. + // zcode patch: video/* file part -> video content block (image-block-isomorphic
  35. + // shape used by Anthropic-style compatible gateways; official Anthropic API has
  36. + // no video block yet). Video bytes are serialized as base64.
  37. + anthropicContent.push({
  38. + type: "video",
  39. + source: {
  40. + type: "base64",
  41. + media_type: part.mediaType,
  42. + data: convertToBase64(part.data)
  43. + },
  44. + cache_control: cacheControl
  45. + });
  46. } else if (part.mediaType === "application/pdf") {
  47. betas.add("pdfs-2024-09-25");
  48. const enableCitations = await shouldEnableCitations(