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

feat: add hubAI() #173

Merged
merged 37 commits into from
Aug 15, 2024
Merged

feat: add hubAI() #173

merged 37 commits into from
Aug 15, 2024

Conversation

RihanArfan
Copy link
Contributor

@RihanArfan RihanArfan commented Jun 18, 2024

Closes #84, Related https://github.com/nuxt-hub/core/tree/feat/ai, Related #174

Adds Workers AI support to Nuxt Hub.

Current issues/notes

Authentication

wrangler requires authentication to use Workers AI bindings locally as the models will still run on Cloudflare and incur usage. As nitro-cloudflare-dev doesn't pass wrangler's console output or show a URL to authenticate, unless you've used wrangler directly with Workers bindings locally before, you get error Error: Not logged in..

I've opened issue nitrojs/nitro-cloudflare-dev#26 upstream to try and get this resolved. A Cloudflare employee has responded and hopefully we get an ETA in a few days.

The current workaround is manually logging in one time system-wide using npx wrangler login.

Alternative workaround is supporting AI through --remote via the proxy so it just runs directly from the Cloudflare account.

If you have access to multiple accounts, see docs below.

Streaming

Output appears mangled. See streaming code snippet below. This may be due to the old model I tried, or from using it via local development in Wrangler.

Details

Response:

data: {"response":" ","p":"abcdefghijklmnopqr"}

data: {"response":" Ah","p":"abcdefghijklmnopqrstuvwxyz0123456789abcdefgh"}

data: {"response":",","p":"abcd"}

data: {"response":" a","p":"abcdefghijklmnopqrstu"}

data: {"response":" curious","p":"abcdefghijklmnopqrstuvwxyz0123456"}

data: {"response":" question","p":"abcdefghijklmno"}

...

data: [DONE]

⚠️ Expected response should be this format but it's not.

data: {"response":"New"}

data: {"response":" York"}

data: {"response":" is"}

data: {"response":" located"}

data: {"response":" in"}

data: {"response":" the"}

...

data: [DONE]

Copy link

pkg-pr-new bot commented Jun 18, 2024

commit: 10821db

pnpm add https://pkg.pr.new/nuxt-hub/core/@nuxthub/core@173

Open in Stackblitz

@RihanArfan
Copy link
Contributor Author

@atinux Where would you like the docs for AI? Under "Server"?

@RihanArfan RihanArfan marked this pull request as ready for review June 18, 2024 23:26
@RihanArfan RihanArfan mentioned this pull request Jun 19, 2024
Copy link
Contributor

atinux commented Jun 20, 2024

Well this is a very good question, I think we should create a new section, any name ideas?

@RihanArfan
Copy link
Contributor Author

I think "✨ AI" with AI and Vectorize within. Other future features like Queues would fit nicely under Server.

Btw is there a reason we're importing types from @nuxt-hub/core existing runtime utils? I copied this format, but I get errors until directly importing the type.

image

image

image

Copy link
Contributor

atinux commented Jun 25, 2024

Did you run npm run prepack and restarted VS COde @RihanArfan ?

@atinux atinux changed the title feat: add ai feat: add hubAI() Aug 1, 2024
@atinux atinux merged commit 5ba86f9 into nuxt-hub:main Aug 15, 2024
4 of 5 checks passed
@RihanArfan RihanArfan deleted the feat/ai branch August 15, 2024 19:51
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.

AI binding support
2 participants