nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
802 stars 35 forks source link

feat: vectorize #177

Open RihanArfan opened 1 week ago

RihanArfan commented 1 week ago

Closes #174, Related #173

Adds basic support for a single Vectorize database without remote proxy or devtools viewer (which can be added later).

Based on top of #173 just so I can use the preview NPM library from Stackblitz since I need it asap. Once #173 goes in, I can rebase or recreate the PR.

Needs docs written, but is simply just accessing Vectorize through Cloudflare bindings accessed via const vectorize = hubVectorize() so their docs apply. https://developers.cloudflare.com/vectorize/reference/client-api/

Keeping it WIP because docs and as it's based on top of #173, but it's ready to be reviewed.

Remaining tasks

pkg-pr-new[bot] commented 1 week ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

commit: aedb7c2

@nuxthub/core

``` npm i https://pkg.pr.new/nuxt-hub/core/@nuxthub/core@177 ```


templates

- [default](https://pkg.pr.new/template/a2cd422c-694c-46c2-9268-63f32f24ca3e)

RihanArfan commented 1 week ago

Turns out Vectorize doesn't support local development, only with wrangler with --remote. This is unlike Workers AI, which supports local development, however models are actually ran on Cloudflare with your account.

Issue tracking Vectorize local bindings: https://github.com/cloudflare/workers-sdk/issues/4360 https://developers.cloudflare.com/workers/testing/local-development/#supported-resource-bindings-in-different-environments

For now, this feature could only be supported with --remote (either via NuxtHub's proxy or wrangler remote). This would involve adding Vectorize to endpoints to NuxtHub's backend and I don't think that's OSS. Alternatively it could be blocked until local development is supported with Vectorize. Alternatively, t

Atinux commented 1 week ago

Thanks for looking at it so quickly.

I think this could anyway be possible within the OSS as you would need to deploy your application at first in order to use Vectorize.

Would you be happy to work on the proxy API routes?

RihanArfan commented 1 week ago

I didn't realise those routes were for anything more than just devtools preview with --remote for some reason lol 😄 I've added the proxy routes, but I don't think I can test them yet. If I understand correctly, bindings are added once the build hook is ran. Could you support adding the Vectorize bindings? Edit: With a fresh mind I realised I can manually add the bindings from CF dash myself 🤦

I'll continue my dissertation where I'll be testing test both AI and Vectorize integrations to build a simple vector search engine.

RihanArfan commented 5 days ago

Vectorize and AI works ✨

image

Got some small things to clean up code wise, which I'll get sorted hopefully by mid July.