Skip to content

Commit ba33684

Browse files
committed
init
0 parents  commit ba33684

25 files changed

+22867
-0
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

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.

app.vue

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script setup lang="ts">
2+
const threadsStore = useThreadsStore();
3+
4+
await callOnce(threadsStore.fetch);
5+
6+
const links = computed(() => {
7+
return threadsStore.threads.map((thread) => {
8+
return {
9+
label: `${new Date(thread.created_at * 1000).toTimeString()} - id ${
10+
thread.id
11+
}`,
12+
icon: "i-heroicons-document-solid",
13+
to: `/threads/${thread.id}`,
14+
};
15+
});
16+
});
17+
</script>
18+
19+
<template>
20+
<div class="flex h-full">
21+
<div class="w-72">
22+
<UVerticalNavigation :links="links" />
23+
</div>
24+
<div class="w-full h-full">
25+
<NuxtPage />
26+
</div>
27+
</div>
28+
</template>
29+
30+
<style>
31+
html,
32+
body,
33+
#__nuxt {
34+
height: 100%;
35+
}
36+
</style>

components/PracticeExam.vue

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script setup lang="ts">
2+
const value = ref("");
3+
4+
async function handleSubmit() {
5+
const startChat = await $fetch("/api/tutor", {
6+
method: "POST",
7+
body: {
8+
message: value.value,
9+
},
10+
});
11+
12+
console.log(startChat);
13+
//
14+
}
15+
16+
async function handleCreateThread() {
17+
await $fetch("/api/threads", {
18+
method: "POST",
19+
});
20+
}
21+
22+
async function handleShowThreads() {
23+
const threads = await $fetch("/api/threads", {
24+
method: "GET",
25+
});
26+
27+
console.log(threads);
28+
//
29+
}
30+
</script>
31+
32+
<template>
33+
<!-- -->
34+
<form @submit.prevent="handleSubmit">
35+
<UTextarea v-model="value" placeholder="Start chatting to AI..." />
36+
<UButton type="submit">Start!</UButton>
37+
</form>
38+
39+
<UButton @click="handleCreateThread">New Conversation</UButton>
40+
<UButton @click="handleShowThreads">List conversations</UButton>
41+
</template>

components/Threads.vue

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
const { data, pending, error, refresh } = await useFetch("/api/threads", {
3+
method: "GET",
4+
});
5+
6+
const links = computed(() => {
7+
return (
8+
data.value?.map((thread) => {
9+
return {
10+
label: new Date(thread.created_at * 1000).toTimeString(),
11+
openai_id: thread.openai_id,
12+
icon: "i-heroicons-document-solid",
13+
to: `/threads/${thread.id}`,
14+
};
15+
}) ?? []
16+
);
17+
});
18+
</script>
19+
20+
<template>
21+
<UVerticalNavigation :links="links" />
22+
</template>

composables/useLoading.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export function useLoading<T>(cb: () => Promise<T>) {
2+
const loading = ref(false);
3+
4+
const run = async () => {
5+
loading.value = true;
6+
await cb();
7+
loading.value = false;
8+
};
9+
10+
return {
11+
run,
12+
loading,
13+
};
14+
}

mydb.sqlite

32 KB
Binary file not shown.

nuxt.config.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({
3+
modules: ["@nuxt/ui", "@pinia/nuxt"],
4+
nitro: {
5+
experimental: {
6+
websocket: true,
7+
},
8+
},
9+
});

0 commit comments

Comments
 (0)