Skip to content

Commit 800e23b

Browse files
committed
Dia 1 - Octubre 2024
1 parent 5467b7e commit 800e23b

File tree

15 files changed

+7460
-0
lines changed

15 files changed

+7460
-0
lines changed

04-frameworks/03-vue/Dia_1/README.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Nuxt 3 Minimal Starter
2+
3+
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4+
5+
## Setup
6+
7+
Make sure to install the dependencies:
8+
9+
```bash
10+
# npm
11+
npm install
12+
13+
# pnpm
14+
pnpm install
15+
16+
# yarn
17+
yarn install
18+
19+
# bun
20+
bun install
21+
```
22+
23+
## Development Server
24+
25+
Start the development server on `http://localhost:3000`:
26+
27+
```bash
28+
# npm
29+
npm run dev
30+
31+
# pnpm
32+
pnpm run dev
33+
34+
# yarn
35+
yarn dev
36+
37+
# bun
38+
bun run dev
39+
```
40+
41+
## Production
42+
43+
Build the application for production:
44+
45+
```bash
46+
# npm
47+
npm run build
48+
49+
# pnpm
50+
pnpm run build
51+
52+
# yarn
53+
yarn build
54+
55+
# bun
56+
bun run build
57+
```
58+
59+
Locally preview production build:
60+
61+
```bash
62+
# npm
63+
npm run preview
64+
65+
# pnpm
66+
pnpm run preview
67+
68+
# yarn
69+
yarn preview
70+
71+
# bun
72+
bun run preview
73+
```
74+
75+
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<template>
2+
<section
3+
class="grid grid-rows-[1fr,200px] h-full px-3 pt-3 pb-5 gap-4 overflow-hidden"
4+
>
5+
<output> </output>
6+
7+
<form @submit.prevent="onSubmit" class="flex justify-end gap-4">
8+
<textarea
9+
class="block w-full resize-none rounded-md p-2 bg-gray-700 border border-1 text-white"
10+
@keydown="onKeyDown"
11+
@keyup="onKeyUp"
12+
autofocus
13+
v-model="message"
14+
></textarea>
15+
<button
16+
class="rounded-md hover:bg-gray-700 hover:text-white p-3 self-end"
17+
>
18+
Send
19+
</button>
20+
</form>
21+
</section>
22+
</template>
23+
24+
<script setup lang="ts">
25+
import { ref } from 'vue';
26+
const message = ref('');
27+
28+
const isShiftPressed = ref(false);
29+
30+
const onKeyDown = (event: KeyBoardEvent) => {
31+
if (event.key === 'Shift') {
32+
isShiftPressed.value = true;
33+
}
34+
};
35+
36+
const onKeyUp = (event: KeyBoardEvent) => {
37+
if (event.key === 'Shift') {
38+
isShiftPressed.value = false;
39+
}
40+
41+
if (event.key === 'Enter' && !isShiftPressed.value) {
42+
onSubmit();
43+
44+
return;
45+
}
46+
};
47+
48+
const ai = useAI();
49+
50+
const onSubmit = async () => {
51+
console.log(message.value);
52+
// loading state
53+
// clear textarea
54+
message.value = '';
55+
56+
const response = await ai.getCompletion(message.value);
57+
58+
console.log({ response });
59+
};
60+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<nav class="border-b border-b-slate-300 p-3">
3+
<nuxt-link to="/">Home</nuxt-link>
4+
</nav>
5+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import ollama from 'ollama';
2+
3+
export default function useAI() {
4+
const getCompletion = async (prompt: string) => {
5+
const response = await ollama.chat({
6+
model: 'llama3.1',
7+
messages: [{ role: 'user', content: prompt }],
8+
});
9+
10+
return response.message.content;
11+
};
12+
13+
return { getCompletion };
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<div>
3+
<header>
4+
<TheNavigation />
5+
</header>
6+
<main>
7+
<slot />
8+
</main>
9+
</div>
10+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({
3+
compatibilityDate: '2024-04-03',
4+
devtools: { enabled: true },
5+
modules: ['@nuxtjs/tailwindcss'],
6+
});
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "nuxt-app",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "nuxt preview",
10+
"postinstall": "nuxt prepare"
11+
},
12+
"dependencies": {
13+
"nuxt": "^3.13.0",
14+
"ollama": "^0.5.9",
15+
"vue": "latest",
16+
"vue-router": "latest"
17+
},
18+
"devDependencies": {
19+
"@nuxtjs/tailwindcss": "^6.12.2"
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<template>About</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<h1>Welcome!</h1>
3+
4+
<ChatTheChat />
5+
</template>

0 commit comments

Comments
 (0)