Skip to content

Commit

Permalink
chore: update deps (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored Jan 8, 2025
1 parent c6fd49a commit a387774
Show file tree
Hide file tree
Showing 7 changed files with 4,028 additions and 4,579 deletions.
8 changes: 4 additions & 4 deletions docs/content/0.index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ database:
title: Database
icon: i-lucide-database
title: A Scalable SQL Database
description: 'NuxtHub Database unlocks the power of <a class="font-semibold text-gray-800 dark:text-gray-300 hover:underline underline-offset-4" href="https://developers.cloudflare.com/d1/" target="_blank">Cloudflare D1</a> to give you access to a serverless SQL database, with zero configuration.
Scale and manage effortlessly, and pay only for what you use.'
description: >
NuxtHub Database unlocks the power of <a class="font-semibold text-gray-800 dark:text-gray-300 hover:underline underline-offset-4" href="https://developers.cloudflare.com/d1/" target="_blank">Cloudflare D1</a> to give you access to a serverless SQL database, with zero configuration. Scale and manage effortlessly, and pay only for what you use.
features:
- name: 'hubDatabase() server helper'
icon: i-lucide-square-function
Expand Down Expand Up @@ -210,8 +210,8 @@ kv:
title: Key-Value
icon: i-lucide-list
title: A Global Key-Value Database
description: 'NuxtHub KV leverages <a href="https://developers.cloudflare.com/kv/" target="_blank" class="font-semibold text-gray-800 dark:text-gray-200 hover:underline underline-offset-4">Cloudflare Workers KV</a> to access a global, low-latency, key-value data storage across 300+ global locations.
Access it in your Nuxt codebase, with zero-configuration.'
description: >
NuxtHub KV leverages <a href="https://developers.cloudflare.com/kv/" target="_blank" class="font-semibold text-gray-800 dark:text-gray-200 hover:underline underline-offset-4">Cloudflare Workers KV</a> to access a global, low-latency, key-value data storage across 300+ global locations. Access it in your Nuxt codebase, with zero-configuration.
features:
- name: 'hubKV() server helper'
icon: i-lucide-square-function
Expand Down
21 changes: 9 additions & 12 deletions docs/content/1.docs/2.features/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ NuxtHub AI is compatible with some functions of the [Vercel AI SDK](https://sdk
Make sure to install the Vercel AI SDK in your project.

```[Terminal]
npx nypm i ai @ai-sdk/vue
npx nypm i ai @ai-sdk/vue workers-ai-provider
```

::note
Expand All @@ -181,21 +181,18 @@ npx nypm i ai @ai-sdk/vue
To leverage the `useChat()` Vue composable, you need to create a `POST /api/chat` endpoint that uses the `hubAI()` server composable and returns a compatible stream for the Vercel AI SDK.

```ts [server/api/chat.post.ts]
import { AIStream, formatStreamPart } from 'ai'
import { streamText } from 'ai'
import { createWorkersAI } from 'workers-ai-provider'

export default defineEventHandler(async (event) => {
const { messages } = await readBody(event)

const stream = await hubAI().run('@cf/meta/llama-3.1-8b-instruct', {
messages,
stream: true
}) as ReadableStream
const workersAI = createWorkersAI({ binding: hubAI() })

// Return a compatible stream for the Vercel AI SDK
return AIStream(
new Response(stream),
data => formatStreamPart('text', JSON.parse(data).response)
)
return streamText({
model: workersAI('@cf/meta/llama-3.1-8b-instruct'),
messages
}).toDataStreamResponse()
})
```

Expand Down Expand Up @@ -227,5 +224,5 @@ const { messages, input, handleSubmit, isLoading, stop, error, reload } = useCha
Learn more about the [`useChat()` Vue composable](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-chat).

::callout
Check out our [`pages/ai.vue` full example](https://github.com/nuxt-hub/core/blob/main/playground/app/pages/ai.vue) with Nuxt UI & Nuxt MDC.
Check out our [`pages/ai.vue` full example](https://github.com/nuxt-hub/core/blob/main/playground/app/pages/ai.vue) with Nuxt UI & [Nuxt MDC](https://github.com/nuxt-modules/mdc).
::
32 changes: 16 additions & 16 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@
"preview": "nuxi preview"
},
"dependencies": {
"@iconify-json/heroicons": "^1.2.1",
"@iconify-json/logos": "^1.2.3",
"@iconify-json/lucide": "^1.2.14",
"@iconify-json/ph": "^1.2.1",
"@iconify-json/simple-icons": "^1.2.11",
"@iconify-json/vscode-icons": "^1.2.2",
"@iconify-json/heroicons": "^1.2.2",
"@iconify-json/logos": "^1.2.4",
"@iconify-json/lucide": "^1.2.22",
"@iconify-json/ph": "^1.2.2",
"@iconify-json/simple-icons": "^1.2.19",
"@iconify-json/vscode-icons": "^1.2.9",
"@nuxt/content": "^2.13.4",
"@nuxt/fonts": "^0.10.2",
"@nuxt/image": "^1.8.1",
"@nuxt/fonts": "^0.10.3",
"@nuxt/image": "^1.9.0",
"@nuxt/scripts": "^0.9.5",
"@nuxt/ui-pro": "^1.5.0",
"@nuxt/ui-pro": "^1.6.0",
"@nuxthq/studio": "^2.2.1",
"@nuxtjs/plausible": "^1.0.3",
"@nuxtjs/plausible": "^1.2.0",
"@nuxtjs/tailwindcss": "^6.12.2",
"@tsparticles/engine": "^3.5.0",
"@tsparticles/slim": "^3.5.0",
"@vueuse/core": "^11.2.0",
"@vueuse/nuxt": "^11.2.0",
"@tsparticles/engine": "^3.7.1",
"@tsparticles/slim": "^3.7.1",
"@vueuse/core": "^12.3.0",
"@vueuse/nuxt": "^12.3.0",
"feed": "^4.2.2",
"medium-zoom": "^1.1.0",
"nuxt": "^3.14.159",
"nuxt": "^3.15.1",
"nuxt-cloudflare-analytics": "^1.0.8",
"nuxt-og-image": "^3.0.8"
"nuxt-og-image": "^4.0.2"
}
}
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,40 @@
"test:watch": "vitest watch"
},
"dependencies": {
"@cloudflare/workers-types": "^4.20241216.0",
"@nuxt/devtools-kit": "^1.6.4",
"@nuxt/kit": "^3.14.1592",
"@uploadthing/mime-types": "^0.3.2",
"@cloudflare/workers-types": "^4.20241230.0",
"@nuxt/devtools-kit": "^1.7.0",
"@nuxt/kit": "^3.15.1",
"@uploadthing/mime-types": "^0.3.4",
"citty": "^0.1.6",
"confbox": "^0.1.8",
"defu": "^6.1.4",
"destr": "^2.0.3",
"h3": "^1.13.0",
"mime": "^4.0.4",
"mime": "^4.0.6",
"nitro-cloudflare-dev": "^0.2.1",
"ofetch": "^1.4.1",
"pathe": "^1.1.2",
"pkg-types": "^1.2.1",
"pathe": "^2.0.0",
"pkg-types": "^1.3.0",
"std-env": "^3.8.0",
"ufo": "^1.5.4",
"uncrypto": "^0.1.3",
"unstorage": "^1.13.1",
"unstorage": "^1.14.4",
"zod": "^3.24.1"
},
"devDependencies": {
"@nuxt/devtools": "^1.6.4",
"@nuxt/eslint-config": "^0.7.3",
"@nuxt/devtools": "^1.7.0",
"@nuxt/eslint-config": "^0.7.4",
"@nuxt/module-builder": "^0.8.4",
"@nuxt/schema": "^3.14.1592",
"@nuxt/schema": "^3.15.1",
"@nuxt/test-utils": "^3.15.1",
"@nuxthub/core": "link:",
"@types/node": "^22.10.2",
"@types/node": "^22.10.5",
"changelogen": "^0.5.7",
"eslint": "^9.17.0",
"nuxt": "^3.14.1592",
"nuxt": "^3.15.1",
"typescript": "5.6.3",
"vitest": "^2.1.8",
"wrangler": "^3.96.0"
"wrangler": "^3.100.0"
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].3"
}
19 changes: 10 additions & 9 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
"preview": "nuxi preview"
},
"dependencies": {
"@ai-sdk/vue": "^0.0.59",
"@ai-sdk/vue": "^1.0.8",
"@cloudflare/puppeteer": "^0.0.14",
"@iconify-json/simple-icons": "^1.2.11",
"@iconify-json/simple-icons": "^1.2.19",
"@kgierke/nuxt-basic-auth": "^1.7.0",
"@nuxt/ui": "^2.19.2",
"@nuxt/ui": "^2.20.0",
"@nuxthub/core": "latest",
"@nuxtjs/mdc": "^0.9.2",
"ai": "^3.4.33",
"@nuxtjs/mdc": "^0.12.1",
"ai": "^4.0.30",
"aws4fetch": "^1.0.20",
"drizzle-orm": "^0.36.1",
"nuxt": "^3.14.159",
"drizzle-orm": "^0.38.3",
"nuxt": "^3.15.1",
"postgres": "^3.4.5",
"puppeteer": "^23.7.1",
"zod": "^3.23.8"
"puppeteer": "^23.11.1",
"workers-ai-provider": "^0.0.10",
"zod": "^3.24.1"
},
"devDependencies": {
"@nuxt/devtools": "latest"
Expand Down
23 changes: 16 additions & 7 deletions playground/server/api/chat.post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AIStream, formatStreamPart } from 'ai'
import { streamText } from 'ai'
import { createWorkersAI } from 'workers-ai-provider'

defineRouteMeta({
openAPI: {
Expand All @@ -10,10 +11,20 @@ defineRouteMeta({
export default defineEventHandler(async (event) => {
const { messages } = await readBody(event)

const stream = await hubAI().run('@cf/meta/llama-3.1-8b-instruct', {
messages,
stream: true
}) as ReadableStream
const workersAI = createWorkersAI({ binding: hubAI() })

return streamText({
model: workersAI('@cf/meta/llama-3.1-8b-instruct'),
messages
}).toDataStreamResponse({
// headers: {
// // add these headers to ensure that the
// // response is chunked and streamed
// 'content-type': 'text/x-unknown',
// 'content-encoding': 'identity',
// 'transfer-encoding': 'chunked'
// }
})

// For testing purposes, we'll randomly throw an error
// if (Math.round(Math.random()) === 1) {
Expand All @@ -22,6 +33,4 @@ export default defineEventHandler(async (event) => {
// statusMessage: 'Nope'
// })
// }

return AIStream(new Response(stream), data => formatStreamPart('text', JSON.parse(data).response))
})
Loading

0 comments on commit a387774

Please sign in to comment.