nuxt-hub / core

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

Unable to deploy with `vectorize` database #369

Closed onmax closed 2 weeks ago

onmax commented 2 weeks ago

Describe the bug

Unable to deploy a project after enabling vectorisation.

I have this project. I have deployed the project several times before.

Now I have added the vectorize feature. Following the code from the docs and the Chat With PDF template, I implemented a task that converts markdowns to embeddings.

As stated in the docs, I need to deploy my project first before trying to insert vectors into the vector database, but I get an error that I don't know how to fix.

My hub config:

export default defineNuxtConfig({
// ...
hub: {
    ai: true,
    database: true,
    vectorize: {
      chunks: {
        // Exactly same as https://github.com/RihanArfan/chat-with-pdf
        dimensions: 1024, // @cf/baai/bge-large-en-v1.5
        metric: 'euclidean',
        metadataIndexes: {
          slug: 'string',
        },
      },
    },
  },
})

Using the CLI

npx nuxthub deploy

I get: ``` βœ– Failed to deploy ninja to production. ERROR [POST] "https://admin.hub.nuxt.com/api/teams/onmax/projects/ninja/deploy": 500 Internal Server Error ```

Using the Dashboard

I push my changes and then I get:

Error in the dasboard

``` .... 13:48:41.193 13:48:41.194 > nuxt-app@ postinstall /opt/buildhome/repo 13:48:41.194 > nuxt prepare 13:48:41.194 13:48:44.416 [info] Nuxt Icon server bundle mode is set to `remote` 13:48:44.703 [info] Running with compatibility version `4` 13:48:45.674 [success] Types generated in .nuxt 13:48:45.710 Done in 17.4s 13:48:45.834 Executing user command: npx nuxi build 13:48:47.250 [log] Nuxt 3.14.0 with Nitro 2.10.2 13:48:51.844 [error] [nuxt:hub] Cannot read properties of undefined (reading 'code') 13:48:51.990 Failed: Error while executing user command. Exited with error code: 1 13:48:52.001 Failed: build command exited with code: 1 13:48:53.058 Failed: error occurred while running build command ```

Removing the vectorize option seems to work, so the issue is exactly enabling the vector database :/

image

Am I missing something?

Please let me know if you need any other context. Thank you! πŸ™Œ

RihanArfan commented 2 weeks ago

Hi @onmax, thank you for reporting this. πŸ˜ƒ I've just tested and I was able to create Vectorize indexes on a new project.

Could you check that your Cloudflare API token for NuxtHub has the vectorize:edit permission? https://dash.cloudflare.com/profile/api-tokens

Let me know if it does and I can look further into this.

onmax commented 2 weeks ago

I re-generated the token and it worked. Thank you!

I will try to remember this kind of stuff for the future :)

PS: Also thanks for your contribution to NuxtHub and vectorize things, super useful πŸ‘