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
Copy file name to clipboardExpand all lines: docs/content/5.blog/3.cloudflare-ai-for-user-experience.md
+15-16Lines changed: 15 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,16 +10,15 @@ authors:
10
10
username: atinux
11
11
date: 2024-08-26
12
12
category: Tutorial
13
-
draft: true
14
13
---
15
14
16
15
## Introduction
17
16
18
17
Let's improve [Atidraw](https://github.com/atinux/atidraw), an open source collaborative drawing app made with Nuxt.
19
18
20
19
The application has basic features such as:
21
-
-Auth with Google, GitHub or Anonymously based on [`nuxt-auth-utils`](https://github.com/Atinux/nuxt-auth-utils)
22
-
-Draw with [`signature_pad`](https://github.com/szimek/signature_pad)
20
+
-Authentication with Google, GitHub or login anonymously based on [`nuxt-auth-utils`](https://github.com/Atinux/nuxt-auth-utils)
21
+
-Drawing with [`signature_pad`](https://github.com/szimek/signature_pad)
23
22
- Upload and store drawings with Cloudflare R2 using [`hubBlob()`](/docs/features/blob)
24
23
25
24
You can play with it on [draw.nuxt.dev](https://draw.nuxt.dev).
@@ -34,7 +33,7 @@ This is important to know how Cloudflare AI models are billed.
34
33
35
34
Cloudflare free allocation allows anyone to use a total of 10,000 Neurons per day at no charge.
36
35
37
-
Neurons are Cloudflare way of measuring AI outputs across different models. To give you a sense of what you can accomplish with 10,000 Neurons, you can generate:
36
+
Neurons are Cloudflare's way of measuring AI outputs across different models. To give you a sense of what you can accomplish with 10,000 Neurons, you can generate one of the following (or an equivalent mix):
38
37
- 100-200 LLM responses
39
38
- 500 translations
40
39
- 500 seconds of speech-to-text audio
@@ -53,7 +52,7 @@ Read more about **Cloudflare AI pricing**.
53
52
54
53
## Add AI to Nuxt
55
54
56
-
To add AI to our Nuxt application, we need to enable the AI feature on our `nuxt.config.ts` file.
55
+
To add AI to our Nuxt application, we need to enable the AI feature in our `nuxt.config.ts` file.
57
56
58
57
```ts [nuxt.config.ts]
59
58
exportdefaultdefineNuxtConfig({
@@ -78,17 +77,17 @@ This will allow the module to call AI models from your linked Cloudflare account
78
77
That's it! We can now use the AI models from Cloudflare using [`hubAI()`](/docs/features/ai).
79
78
::
80
79
81
-
I've been thinking on two features:
80
+
I've been thinking about two features:
82
81
- Generate the alternative text for the user drawings, improving the accessibility of the application & SEO.
83
-
- Generate an image based from the drawing and the alternative text, as a way to make the application more interactive.
82
+
- Generate an image based on the drawing and the alternative text, as a way to make the application more interactive.
84
83
85
84
Before starting, I took a look at [Cloudflare's multi modal playground](https://multi-modal.ai.cloudflare.com/) and played with some models.
86
85
87
86
:nuxt-img{alt="Atidraw AI models"dataZoomSrc="/images/blog/atidraw-ai-models.png"height="515"src="/images/blog/atidraw-ai-models.png"width="915"}
88
87
89
88
This guided me to the following models:
90
-
-[LLaVA](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/) for the alternative text
91
-
-[Stable Diffusion IMG2IMG](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-img2img/) for the alternative drawing
89
+
-[LLaVA](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/) for the alternative text generation
90
+
-[Stable Diffusion IMG2IMG](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-img2img/) for the alternative drawing generation
As you can see, we store the pathname of the AI generated image in the custom metadata of the drawing.
247
+
As you can see, we store the `pathname` of the AI generated image in the custom metadata of the drawing.
249
248
250
-
Now, we can display the AI generated image in the listing page when hovering the user's drawing:
249
+
Now, we can display the AI generated image in our listing page when hovering the user's drawing:
251
250
252
251
```vue [app/pages/index.vue]
253
252
<script setup lang="ts">
@@ -290,12 +289,12 @@ I am quite happy with the result:
290
289
::
291
290
292
291
::note
293
-
Sometime the AI generated image is black, this is because the model is not able to generate an image from the description, most of the time because it is a sensitive content or misunderstood the description.
292
+
Sometimes the AI generated image is black, this is because the model is not able to generate an image from the description, most of the time because it is sensitive content or it misunderstood the description.
294
293
::
295
294
296
295
## Conclusion
297
296
298
-
This is the end of this tutorial on how to use Cloudflare AI models in a Nuxt application. I hope you enjoyed it and that it gave you some ideas on how to use AI in your Nuxt application.
297
+
This is the end of this tutorial on how to use Cloudflare AI models in a Nuxt application. I hope you enjoyed it and that it gave you some ideas on how to use AI for improving accessibility, SEO or User Experience.
299
298
300
299
Feel free to expand on this foundation and add your own unique features to make Atidraw yours!
0 commit comments