You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This feature is available from [`@nuxthub/core >= v0.8.26`](https://github.com/nuxt-hub/core/releases/tag/v0.8.26)
16
+
::
17
+
18
+
19
+
We are excited to introduce [`hubAutoRAG()`](/docs/features/autorag). Cloudflare [AutoRAG](https://developers.cloudflare.com/autorag/) lets you create fully-managed, retrieval-augmented generation pipelines that continuously updates and scales on Cloudflare. With AutoRAG, you can integrate context-aware AI into your Nuxt applications without managing infrastructure.
20
+
21
+
If you are currently using [`hubVectorize()`](/docs/features/vectorize), you may be interested in switching to `hubAutoRAG()` for a simplified developer experience. AutoRAG automatically indexes your data into vector embeddings optimized for semantic search. Once a data source is connected, indexing runs continuously in the background to keep your knowledge base fresh and queryable.
22
+
23
+
## How to use hubAutoRAG()
24
+
25
+
1. Update `@nuxthub/core` to the latest version (`v0.8.26` or later)
26
+
27
+
2. Enable `hub.ai` in your `nuxt.config.ts`
28
+
29
+
```ts [nuxt.config.ts]
30
+
exportdefaultdefineNuxtConfig({
31
+
hub: {
32
+
ai: true
33
+
}
34
+
})
35
+
```
36
+
37
+
3. Create an AutoRAG instance from the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/ai/autorag) and add your data source.
Go to [AutoRAG](https://dash.cloudflare.com/?to=/:account/ai/autorag) in the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/ai/autorag)
41
+
::
42
+
43
+
4. Start using [`hubAutoRAG()`](/docs/features/browser) in your server routes
Options for configuring [`AI Gateway`](#ai-gateway) - `id`, `skipCache`, and `cacheTtl`.
103
+
Options for configuring [`AI Gateway`](#ai-gateway) - `id`, `skipCache`, and `cacheTtl`.
104
104
::
105
105
::
106
106
107
+
### `models()`
108
+
109
+
List all available models programatically.
110
+
111
+
```ts [server/api/models-test.ts]
112
+
exportdefaultdefineEventHandler(async () => {
113
+
const ai =hubAI() // access AI bindings
114
+
returnawaitai.models({ page: 2 })
115
+
})
116
+
```
117
+
118
+
#### Options
119
+
120
+
::field-group
121
+
::field{name="params"type="object"}
122
+
::collapsible
123
+
::field{name="author" type="string"}
124
+
The author of the model to filter by.
125
+
126
+
::field{name="hide_experimental" type="boolean"}
127
+
Whether to hide experimental models.
128
+
129
+
::field{name="page" type="number"}
130
+
The page of results to return.
131
+
132
+
::field{name="per_page" type="number"}
133
+
The number of results to return per page.
134
+
135
+
::field{name="search" type="string"}
136
+
A search term to filter models by.
137
+
138
+
::field{name="source" type="number"}
139
+
The source ID to filter by.
140
+
141
+
::field{name="task" type="string"}
142
+
The task name to filter by.
143
+
::
144
+
::
145
+
::
107
146
108
147
## Tools
109
148
110
-
Tools are actions that your LLM can execute to run functions or interact with external APIs. The result of these tools will be used by the LLM to generate additional responses.
149
+
Tools are actions that your LLM can execute to run functions or interact with external APIs. The result of these tools will be used by the LLM to generate additional responses.
111
150
112
-
This can help you supply the LLM with real-time information, save data to a KV store, or provide it with external data from your database.
151
+
This can help you supply the LLM with real-time information, save data to a KV store, or provide it with external data from your database.
113
152
114
153
With Workers AI, tools have 4 properties:
115
154
-`name`: The name of the tool
@@ -125,7 +164,7 @@ const tools = [
125
164
parameters: {
126
165
type: 'object',
127
166
properties: {
128
-
city: {
167
+
city: {
129
168
type: 'number',
130
169
description: 'The city to retrieve weather information for'
131
170
},
@@ -152,7 +191,7 @@ const tools = [
152
191
::
153
192
154
193
::field{name="parameters"type="JsonSchema7"}
155
-
The parameters and options for parameters that the model will use to run the tool.
194
+
The parameters and options for parameters that the model will use to run the tool.
156
195
::collapsible
157
196
::field{name="type" type="string"}
158
197
The type of your functions parameter. It's recommended to use an `object` so you can easily add additional properties in the future.
@@ -189,7 +228,7 @@ npx nypm i @cloudflare/ai-utils
Controls the [Cache TTL](https://developers.cloudflare.com/ai-gateway/configuration/caching/#cache-ttl-cf-cache-ttl), the duration (in seconds) that a cached request will be valid for. The minimum TTL is 60 seconds and maximum is one month.
342
+
Controls the [Cache TTL](https://developers.cloudflare.com/ai-gateway/configuration/caching/#cache-ttl-cf-cache-ttl), the duration (in seconds) that a cached request will be valid for. The minimum TTL is 60 seconds and maximum is one month.
304
343
::
305
344
::
306
345
@@ -310,7 +349,7 @@ The recommended method to handle text generation responses is streaming.
310
349
311
350
LLMs work internally by generating responses sequentially using a process of repeated inference — the full output of a LLM model is essentially a sequence of hundreds or thousands of individual prediction tasks. For this reason, while it only takes a few milliseconds to generate a single token, generating the full response takes longer.
312
351
313
-
If your UI waits for the entire response to be generated, a user may see a loading spinner for several seconds before the response is displayed.
352
+
If your UI waits for the entire response to be generated, a user may see a loading spinner for several seconds before the response is displayed.
314
353
315
354
Streaming lets you start displaying the response as soon as the first tokens are generated, and append each additional token until the response is complete. This yields a much better experience for the end user. Displaying text incrementally as it’s generated not only provides instant responsiveness, but also gives the end-user time to read and interpret the text.
316
355
@@ -386,7 +425,7 @@ npx nypm i ai @ai-sdk/vue workers-ai-provider
386
425
387
426
### `useChat()`
388
427
389
-
`useChat()` is a Vue composable provided by the Vercel AI SDK that handles streaming responses, API calls, state for your chat.
428
+
`useChat()` is a Vue composable provided by the Vercel AI SDK that handles streaming responses, API calls, state for your chat.
390
429
391
430
It requires a `POST /api/chat` endpoint that uses the `hubAI()` server composable and returns a compatible stream for the Vercel AI SDK.
392
431
@@ -457,6 +496,6 @@ Explore open source templates made by the community:
0 commit comments