Comments (2)
shouldn't it be in another repository? like @nuxthub/ai
? (related project from Daniel: https://www.twitch.tv/videos/2127437533?t=01h00m20s)
from core.
Here's a patch to get AI bindings in a NuxtHub project locally. Also it was fun being in Daniel's stream chat sharing what I knew to help :P
- Create
patches/@[email protected]
with the following contents:
diff --git a/dist/module.d.ts b/dist/module.d.ts
index b98d0a4d25d093fc791b0b889d83333b1d6e65cf..18ad766c03b7ece29876a73e7c683006f05608a2 100644
--- a/dist/module.d.ts
+++ b/dist/module.d.ts
@@ -37,6 +37,13 @@ interface ModuleOptions {
* @see https://hub.nuxt.com/docs/storage/kv
*/
kv?: boolean;
+ /**
+ * Set `true` to enable AI for the project.
+ *
+ * @default false
+ * @see https://developers.cloudflare.com/workers-ai/
+ */
+ ai?: boolean;
/**
* Set to `true`, 'preview' or 'production' to use the remote storage.
* Only set the value on a project you are deploying outside of NuxtHub or Cloudflare.
diff --git a/dist/module.mjs b/dist/module.mjs
index 9677d7e3d2840219959d03643ad488e2c8df6f73..f216bc64131bff83365a16d178b7c8c24c1a118b 100644
--- a/dist/module.mjs
+++ b/dist/module.mjs
@@ -27,6 +27,11 @@ function generateWrangler(hub) {
bucket_name: "default"
}];
}
+ if (hub.ai) {
+ wrangler["ai"] = {
+ binding: "AI"
+ };
+ }
if (hub.cache || hub.kv) {
wrangler["kv_namespaces"] = [];
if (hub.kv) {
@@ -249,7 +254,8 @@ function addBuildHooks(nuxt, hub) {
blob: hub.blob,
cache: hub.cache,
database: hub.database,
- kv: hub.kv
+ kv: hub.kv,
+ ai: hub.ai,
}
}).catch((e) => {
if (e.response?._data?.message) {
@@ -352,6 +358,7 @@ const module = defineNuxtModule({
cache: false,
database: false,
kv: false,
+ ai: false,
// Other options
version,
env: process.env.NUXT_HUB_ENV || "production",
- Edit
package.json
and add thepnpm
section.
{
...
"dependencies": {
"@nuxthub/core": "^0.6.10",
...
},
"pnpm": {
"patchedDependencies": {
"@nuxthub/[email protected]": "patches/@[email protected]"
}
}
}
- Apply patch with
pnpm install
- Enable AI in your NuxtHub config inside
nuxt.config.ts
export default defineNuxtConfig({
hub: {
cache: true,
database: true,
ai: true,
},
...
})
- Start your dev server
pnpm dev
and login to Cloudflare if prompted by Wrangler. Workers AI uses account quota even in local development. If you're not prompted to login to Wrangler (since Wrangler logs not shown) then create a dummy Workers AI template and start it with C3 so you can login, then delete the local files after. - https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/
from core.
Related Issues (20)
- 403 error with D1 but R2 authenticates when using remote storage
- [Admin Console] No info/error when repo is not available HOT 1
- adding the NuxtHub module give me error with throw createError HOT 2
- [Admin Console] Can't find organization repositories HOT 1
- useNitroApp() don't access values from plugin in prod HOT 2
- Nuxt 4 support should be turned off by default HOT 1
- Local Development Server works fine but deploying to NuxtHub results in a `500` Error on all pages HOT 1
- [Admin] Hide delete team button when not possible HOT 1
- Support Cloudflare Hyperdrive connection in Nuxt-hub HOT 1
- Command to copy production database into preview HOT 1
- [ADMIN| Better error message when call to database fails HOT 1
- [Feature]: Allow linking the same repository to multiple projects HOT 2
- [Admin Console] "Too many API requests by single worker invocation." when opening large cache HOT 2
- [nuxt] [request error] [unhandled] [500] global is not defined HOT 5
- Dependency Dashboard
- [Admin Console] Can't delete database entries without id HOT 3
- [Admin Console] DB Table Header is hard to read when scrolling
- Im getting error "Error when creating the project Cannot read properties of null (reading 'find')". HOT 1
- Cloudflare - Durable Object support HOT 1
- Missing DB Binding (D1) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.