@camelai/run-vue
@camelai/run-vue
Vue 3 bindings for a chat with an agent on camelRun, through your server's route
(createAgentHandler from @camelai/run/server; see the Frontend guide).
<script setup lang="ts">
import { ref } from "vue";
import { useAgentChat } from "@camelai/run-vue";
const { messages, status, send, stop } = useAgentChat({ endpoint: "/api/agent" });
const text = ref("");
</script>
<template>
<div v-for="message in messages" :key="message.id">
<p v-if="message.role === 'user'">{{ message.text }}</p>
<template v-else v-for="part in message.parts" :key="part.id">
<p v-if="part.type === 'text'">{{ part.text }}</p>
<small v-else-if="part.type === 'tool'">{{ part.name }}: {{ part.state }}</small>
</template>
</div>
<form @submit.prevent="send(text); text = ''"><input v-model="text" /><button>Send</button></form>
<button v-if="status === 'streaming'" @click="stop()">Stop</button>
</template>
useAgentChat(options | chat) returns refs (messages, status, inputs, error, hasOlder,
snapshot) and actions (send, answer, decline, stop, retry, loadOlder, fileUrl); the chat
is connected until the component unmounts. provideAgentChat / useAgent share one chat with
descendants. Render markdown with parseMarkdown from @camelai/run/markdown.
Version History
| Version | Released | License |
|---|---|---|
| 0.22.1 | MIT | |
| 0.22.0 | MIT | |
| 0.21.0 | MIT | |
| 0.20.0 | MIT | |
| 0.19.0 | MIT | |
| 0.18.0 | MIT | |
| 0.17.0 | MIT | |
| 0.16.0 | MIT | |
| 0.15.0 | MIT | |
| 0.14.0 | MIT | |
| 0.13.0 | MIT | |
| 0.12.0 | MIT | |
| 0.11.2 | MIT | |
| 0.11.1 | MIT | |
| 0.11.0 | MIT | |
| 0.0.0 | MIT |