Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Workers Ai fetcher api #1877

Merged
merged 7 commits into from
Mar 27, 2024
Merged

Conversation

G4brym
Copy link
Member

@G4brym G4brym commented Mar 22, 2024

No description provided.

Copy link

github-actions bot commented Mar 22, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@G4brym
Copy link
Member Author

G4brym commented Mar 22, 2024

I have read the CLA Document and I hereby sign the CLA

@G4brym
Copy link
Member Author

G4brym commented Mar 22, 2024

recheck

github-actions bot added a commit that referenced this pull request Mar 22, 2024
@irvinebroque
Copy link
Collaborator

More tests seem worthwhile here?

src/cloudflare/internal/ai-api.ts Show resolved Hide resolved
(
name = "ai",
wrapped = (
moduleName = "cloudflare-internal:ai-api",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, internal implies it shouldn't be used by end users. But this isn't the case here, right? Maybe this shouldn't be an internal module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humm, but end users shouldn't be able to initialize the Ai class on themself, it should be done by wrangler automatically when they define the AI binding
I've kept the code in the internal folder, but added a mapping outside to end users could import the options and Ai class from cloudflare:ai

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do other APIs do? What is the pattern we want people to use for this @mikea ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, internal implies it shouldn't be used by end users.

cloudflare-internal:ai-api should indeed not be importable by end user.

In the case of a wrapped binding the module must be an internal one. See here:

https://github.com/cloudflare/workerd/blob/main/src/workerd/server/workerd.capnp#L508

The idea is that config is not managed by application developer, but by service provider, so that is a protection from application developer messing with bindings from code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm currently having some issues importing this module from wrangler iv'e tried with cloudflare:ai and cloudflare-internal:ai-api
image

@G4brym G4brym force-pushed the poc-workers-ai-fetcher branch 3 times, most recently from 2dccee5 to 285b95c Compare March 25, 2024 13:02
@G4brym
Copy link
Member Author

G4brym commented Mar 25, 2024

@irvinebroque i've just added more tests now

Copy link
Collaborator

@mikea mikea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code (and test) structure LG to me. I don't have much opinion on the API itself or its implementation detail.

@G4brym
Copy link
Member Author

G4brym commented Mar 26, 2024

Was able to successfully test this pull request together with the wrangler pull request here and i've confirmed that it is working as expected

@irvinebroque
Copy link
Collaborator

Can we merge this so that it can go out in a workerd release for Wrangler, and then EW?

@G4brym
Copy link
Member Author

G4brym commented Mar 27, 2024

Everything ready from my side

@kflansburg kflansburg merged commit 80acd74 into cloudflare:main Mar 27, 2024
10 checks passed
dom96 added a commit that referenced this pull request Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants