diff --git a/app/components/chat/Header.vue b/app/components/chat/Header.vue new file mode 100644 index 0000000..1ec9b4b --- /dev/null +++ b/app/components/chat/Header.vue @@ -0,0 +1,79 @@ + + + + + + + + + {{ currentAgent.name }} + + + + + + + + + Name + + + {{ currentAgent.name }} + + + + + Description + + + {{ currentAgent.description }} + + + + + Model + + + {{ currentAgent.defaultModel }} + + + + + Prompt + + + {{ currentAgent.prompt }} + + + + + + + + + \ No newline at end of file diff --git a/app/composables/chat.ts b/app/composables/chat.ts index d20b11f..1f815e3 100644 --- a/app/composables/chat.ts +++ b/app/composables/chat.ts @@ -1,37 +1,55 @@ import type { Message } from 'ai' -export async function loadChat(slug: string): Promise { - const { blobs } = await $fetch('/api/files') - - if (!blobs.find(item => item.pathname === `chats/${slug}.json`)) { - await createChat(slug) +export async function useChatFile() { + const toast = useToast() + async function loadChat(slug: string): Promise { + if (!slug) { + throw createError({ + statusCode: 400, + statusMessage: 'Slug is required', + message: 'Slug is required', + }) + } + + const { blobs } = await $fetch('/api/files') + + if (!blobs.find(item => item.pathname === `chats/${slug}.json`)) { + await createChat(slug) + } + + const data = await $fetch(`/api/chats/${slug}`) + const dataString = JSON.stringify(data) + + if (dataString === '[]') + return [] + return JSON.parse(dataString) + } + + async function createChat(slug: string) { + await $fetch('/api/chats', { + method: 'POST', + body: { + file: { + name: `${slug}.json`, + content: '[]', + }, + }, + }) + } + + async function deleteChat(slug: string) { + await $fetch('/api/files', { + method: 'DELETE', + body: { + pathname: `chats/${slug}.json`, + }, + }) + } + + return { + loadChat, + createChat, + deleteChat, } - const data = await $fetch(`/api/chats/${slug}`) - const dataString = JSON.stringify(data) - - if (dataString === '[]') - return [] - return JSON.parse(dataString) -} - -async function createChat(slug: string) { - await $fetch('/api/chats', { - method: 'POST', - body: { - file: { - name: `${slug}.json`, - content: '[]', - }, - }, - }) -} - -export async function deleteChat(slug: string) { - await $fetch('/api/files', { - method: 'DELETE', - body: { - pathname: `chats/${slug}.json`, - }, - }) -} +} \ No newline at end of file diff --git a/app/pages/[agent].vue b/app/pages/[agent].vue index 0b7882e..4c1e002 100644 --- a/app/pages/[agent].vue +++ b/app/pages/[agent].vue @@ -1,28 +1,20 @@
+ {{ currentAgent.name }} +
+ Name +
+ Description +
+ {{ currentAgent.description }} +
+ Model +
+ {{ currentAgent.defaultModel }} +
+ Prompt +
+ {{ currentAgent.prompt }} +