Add native run binding for Workers AI#5371
Add native run binding for Workers AI#5371mrbbot merged 2 commits intocloudflare:mainfrom G4brym:improve-workers-ai-binding
Conversation
🦋 Changeset detectedLatest commit: c49bf87 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8498132672/npm-package-wrangler-5371You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5371/npm-package-wrangler-5371Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8498132672/npm-package-wrangler-5371 dev path/to/script.jsAdditional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8498132672/npm-package-create-cloudflare-5371 --no-auto-updatenpm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8498132672/npm-package-cloudflare-kv-asset-handler-5371npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8498132672/npm-package-miniflare-5371npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8498132672/npm-package-cloudflare-pages-shared-5371npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8498132672/npm-package-cloudflare-vitest-pool-workers-5371Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
|
Will this change the user experience for local dev? |
|
@admah yes, user will be able to use Workers ai without installing the |
|
@G4brym — assume this need to go out in wrangler for next week? ready for review? Think @craigsdennis trying to build something using new binding |
|
@irvinebroque only now i could finish the pr, because workerd was only released this morning |
|
I'm not sure if miniflare needs to be released first, as this wrangler changes depends on a miniflare release |
|
Think PR description would help here as took a sec to wrap my head around why this needed to refactor bit of Miniflare. Tests fail only with your changes or also with latest workerd? Have you dug in? Bumped here to test: #5451 https://github.com/cloudflare/workers-sdk/blob/main/packages/miniflare/test/index.spec.ts#L1177 https://github.com/cloudflare/workers-sdk/blob/main/packages/miniflare/test/index.spec.ts#L19 https://github.com/cloudflare/workers-sdk/blob/main/packages/miniflare/test/index.spec.ts#L1156 |
|
Tests fail without the Miniflare changes, just when bumping workerd to latest. |
|
Believe cloudflare/workerd@5a4beaa is the only Queues related commit that went out in latest workerd release. @sesteves — not totally sure if cause, but wanted to flag |
|
#5455 should bump |
There was a problem hiding this comment.
| wrappedBindings?: Record<string, object>; |
There was a problem hiding this comment.
| | "wrappedBindings" |
...but add this to the Pick for WorkerOptionsBindings above.
There was a problem hiding this comment.
Ideally, we shouldn't be mutating the config object passed in here. Instead, I would construct an empty wrappedBindings object above this if block with the type WorkerOptions["wrappedBindings"], then modify that here if AI is enabled:
const wrappedBindings: WorkerOptions["wrappedBindings"] = {};
if (bindings.ai?.binding) {
// ...
wrappedBindings[bindings.ai.binding] = {
scriptName: EXTERNAL_AI_WORKER_NAME,
};
}
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5371 +/- ##
==========================================
+ Coverage 72.15% 72.27% +0.12%
==========================================
Files 326 326
Lines 16848 16853 +5
Branches 4311 4311
==========================================
+ Hits 12156 12180 +24
+ Misses 4692 4673 -19
|
|
Thanks, i've rebased the pr, implemented the suggestions and tests are now passing 👍 |
Co-authored-by: MrBBot <me@mrbbot.dev>
|
Hey @mrbbot i don't have permissions to merge this pr, can you merge it please? |
What this PR solves / how to test
Adds native binding for workers ai.
CR-852557
Author has addressed the following