ai icon indicating copy to clipboard operation
ai copied to clipboard

Reject non-image chat file parts in workers-ai-provider

Open slegarraga opened this issue 5 months ago • 1 comments

Summary

  • validate Workers AI chat file parts have an image/* media type before converting them to image_url
  • preserve the provided image media type instead of defaulting missing media types to image/png
  • add regression tests and a changeset for the published provider

Fixes #541.

Testing

  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter workers-ai-provider exec vitest test/convert-to-workersai-chat-messages.test.ts --run
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter workers-ai-provider run type-check
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter workers-ai-provider run build
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm lint

slegarraga avatar Jun 11 '26 11:06 slegarraga

🦋 Changeset detected

Latest commit: 7fd870bcc1ad0900cc409e46c89d4f2afd755612

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
workers-ai-provider Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jun 11 '26 11:06 changeset-bot[bot]

Open in StackBlitz

npx https://pkg.pr.new/cloudflare/ai/ai-gateway-provider@563
npx https://pkg.pr.new/cloudflare/ai/@cloudflare/tanstack-ai@563
npx https://pkg.pr.new/cloudflare/ai/workers-ai-provider@563

commit: 7fd870b

pkg-pr-new[bot] avatar Jun 15 '26 15:06 pkg-pr-new[bot]