-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
7,460 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Nuxt 3 Minimal Starter | ||
|
||
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. | ||
|
||
## Setup | ||
|
||
Make sure to install the dependencies: | ||
|
||
```bash | ||
# npm | ||
npm install | ||
|
||
# pnpm | ||
pnpm install | ||
|
||
# yarn | ||
yarn install | ||
|
||
# bun | ||
bun install | ||
``` | ||
|
||
## Development Server | ||
|
||
Start the development server on `http://localhost:3000`: | ||
|
||
```bash | ||
# npm | ||
npm run dev | ||
|
||
# pnpm | ||
pnpm run dev | ||
|
||
# yarn | ||
yarn dev | ||
|
||
# bun | ||
bun run dev | ||
``` | ||
|
||
## Production | ||
|
||
Build the application for production: | ||
|
||
```bash | ||
# npm | ||
npm run build | ||
|
||
# pnpm | ||
pnpm run build | ||
|
||
# yarn | ||
yarn build | ||
|
||
# bun | ||
bun run build | ||
``` | ||
|
||
Locally preview production build: | ||
|
||
```bash | ||
# npm | ||
npm run preview | ||
|
||
# pnpm | ||
pnpm run preview | ||
|
||
# yarn | ||
yarn preview | ||
|
||
# bun | ||
bun run preview | ||
``` | ||
|
||
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<section | ||
class="grid grid-rows-[1fr,200px] h-full px-3 pt-3 pb-5 gap-4 overflow-hidden" | ||
> | ||
<output> </output> | ||
|
||
<form @submit.prevent="onSubmit" class="flex justify-end gap-4"> | ||
<textarea | ||
class="block w-full resize-none rounded-md p-2 bg-gray-700 border border-1 text-white" | ||
@keydown="onKeyDown" | ||
@keyup="onKeyUp" | ||
autofocus | ||
v-model="message" | ||
></textarea> | ||
<button | ||
class="rounded-md hover:bg-gray-700 hover:text-white p-3 self-end" | ||
> | ||
Send | ||
</button> | ||
</form> | ||
</section> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
const message = ref(''); | ||
const isShiftPressed = ref(false); | ||
const onKeyDown = (event: KeyBoardEvent) => { | ||
if (event.key === 'Shift') { | ||
isShiftPressed.value = true; | ||
} | ||
}; | ||
const onKeyUp = (event: KeyBoardEvent) => { | ||
if (event.key === 'Shift') { | ||
isShiftPressed.value = false; | ||
} | ||
if (event.key === 'Enter' && !isShiftPressed.value) { | ||
onSubmit(); | ||
return; | ||
} | ||
}; | ||
const ai = useAI(); | ||
const onSubmit = async () => { | ||
console.log(message.value); | ||
// loading state | ||
// clear textarea | ||
message.value = ''; | ||
const response = await ai.getCompletion(message.value); | ||
console.log({ response }); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<nav class="border-b border-b-slate-300 p-3"> | ||
<nuxt-link to="/">Home</nuxt-link> | ||
</nav> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import ollama from 'ollama'; | ||
|
||
export default function useAI() { | ||
const getCompletion = async (prompt: string) => { | ||
const response = await ollama.chat({ | ||
model: 'llama3.1', | ||
messages: [{ role: 'user', content: prompt }], | ||
}); | ||
|
||
return response.message.content; | ||
}; | ||
|
||
return { getCompletion }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<div> | ||
<header> | ||
<TheNavigation /> | ||
</header> | ||
<main> | ||
<slot /> | ||
</main> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
compatibilityDate: '2024-04-03', | ||
devtools: { enabled: true }, | ||
modules: ['@nuxtjs/tailwindcss'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "nuxt-app", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "nuxt build", | ||
"dev": "nuxt dev", | ||
"generate": "nuxt generate", | ||
"preview": "nuxt preview", | ||
"postinstall": "nuxt prepare" | ||
}, | ||
"dependencies": { | ||
"nuxt": "^3.13.0", | ||
"ollama": "^0.5.9", | ||
"vue": "latest", | ||
"vue-router": "latest" | ||
}, | ||
"devDependencies": { | ||
"@nuxtjs/tailwindcss": "^6.12.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<template>About</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<h1>Welcome!</h1> | ||
|
||
<ChatTheChat /> | ||
</template> |
Oops, something went wrong.