Skip to content

Conversation

@RihanArfan
Copy link
Member

@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]

@pkg-pr-new
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
Member 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
Member 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
@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