37 lines
1.3 KiB
Vue
37 lines
1.3 KiB
Vue
<script setup lang="ts">
|
|
const { createTopic, fetchingTopics } = await useTopics();
|
|
const { activeAgent } = await useAgents();
|
|
|
|
const creatingTopic = ref(false);
|
|
|
|
const handleSubmit = async (message: string) => {
|
|
// create a new topic, and send the message to it
|
|
console.log('handleSubmit', message);
|
|
if (!activeAgent.value) return;
|
|
|
|
creatingTopic.value = true
|
|
try {
|
|
const newTopic = await createTopic('New Topic', activeAgent.value.id)
|
|
// Navigate to the new topic
|
|
await navigateTo(`/agent/${activeAgent.value.id}/topic/${newTopic.id}`)
|
|
} catch (error) {
|
|
console.error('Failed to create topic:', error)
|
|
} finally {
|
|
creatingTopic.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex h-full w-full pb-4 justify-center">
|
|
<div class="max-w-4xl h-full w-full flex flex-col">
|
|
<!-- chat pane -->
|
|
<div class="flex h-full flex-col gap-2 justify-end mb-28">
|
|
<h1 v-if="activeAgent" class="font-bold">{{ activeAgent.name }}</h1>
|
|
<p class="text-[var(--color-subtle)]">Select a topic to continue or create a new one</p>
|
|
</div>
|
|
|
|
<ChatInput @submit="handleSubmit" :loading="fetchingTopics" />
|
|
</div>
|
|
</div>
|
|
</template> |