Introduction
AaaS Pilot Kit SDK optimized for Vue 3 applications, based on Composition API and dependency injection.
Features
- 🪝 Composition API -
useAaaSPilotKit,useConversation,useConversationListand other composables - 🎯 Dependency Injection -
provideAaaSPilotKitfollows Vue 3 provide/inject standard paradigm, manages global state, implements cross-component state sharing - 📦 TypeScript Support - Complete type definitions, consistent with core library types
- ⚡ Performance Optimization - Built-in reactive state management, automatic controller lifecycle handling
- 🔄 Event System - Simplified event listener interface, supports streaming content updates
- 💡 Vue 3 Native - Fully leverages Vue 3's reactive system and Composition API
Installation
Unified use of public package @bdky/aaas-pilot-kit-vue3.
npm
$ npm install @bdky/aaas-pilot-kit-vue3
yarn
$ yarn add @bdky/aaas-pilot-kit-vue3
Core API
Provider and Dependency Injection
| Function | Feature | Use Case |
|---|---|---|
provideAaaSPilotKit | Create and provide controller instance | Initialize in root component |
useAaaSPilotKit | Get controller and state | Access functionality in child components |
injectAaaSPilotKit | Underlying dependency injection function | Advanced usage and custom wrapping |
Core Composables
| Composable | Feature | Return Value |
|---|---|---|
useAaaSPilotKit | Get controller and state | {controller, isReady, isMuted, isRendering, create, dispose} |
useAaaSPilotKitEvents | Bind event listeners | void |
useConversationList | Get conversation list | {conversationList} |
useConversation | Handle single conversation content | {conversationContents} |
Event Handling
Simplified event listener interface, supports all core library events:
<script setup lang="ts">
useAaaSPilotKitEvents({
onReady: () => console.log('Ready'),
onAsrMessage: (payload) => console.log('ASR Result:', payload.text),
onRenderStart: (payload) => console.log('Start Rendering:', payload),
onConversationChange: (payload) => updateUI(payload)
});
</script>
Advanced Features
Custom AgentService
When you need to connect to a private Agent streaming API protocol, you can create a custom Agent service class by extending BaseAgentService:
<script setup lang="ts">
import {provideAaaSPilotKit} from '@bdky/aaas-pilot-kit-vue3';
const options = {
token: 'your-auth-token-here',
figureId: '209337',
ttsPer: 'LITE_audiobook_female_1',
agentService: CustomAgentService // Replace agentConfig, then agentConfig can be omitted
};
// Pass in custom AgentService
provideAaaSPilotKit(options);
</script>
⚠️ Note: When using custom agentService, agentConfig configuration is not available.
Detailed Implementation Guide: Custom AgentService Configuration
Streaming Conversation Rendering
Parent Component - Get Conversation List
<template>
<div>
<ConversationItem
v-for="conversation in conversationList"
:key="conversation.id"
:conversation="conversation"
/>
</div>
</template>
<script setup lang="ts">
import {useConversationList} from '@bdky/aaas-pilot-kit-vue3';
import ConversationItem from './ConversationItem.vue';
const {conversationList} = useConversationList();
</script>
Child Component - Render Single Conversation Content
<template>
<div>
<div
v-for="item in conversationContents"
:key="item.uiId"
:class="['message', item.mod]"
>
<strong>{{ item.mod }}</strong>
<div>{{ item.content }}</div>
<span>{{ item.completed ? 'Complete' : 'In Progress' }}</span>
</div>
</div>
</template>
<script setup lang="ts">
import {useConversation} from '@bdky/aaas-pilot-kit-vue3';
import {toRef} from 'vue';
import type {AnyConversation} from '@bdky/aaas-pilot-kit';
const props = defineProps<{
conversation: AnyConversation | undefined;
}>();
const {conversationContents} = useConversation(toRef(props, 'conversation'));
</script>
toRef?Since conversation is passed in via props, directly destructuring props.conversation loses reactivity. Using toRef(props, 'conversation') creates a ref pointing to the props property, ensuring that when the conversation passed from the parent component changes, useConversation can reactively update conversationContents.
Lifecycle Management
<script setup lang="ts">
import {nextTick} from 'vue';
import {useAaaSPilotKit} from '@bdky/aaas-pilot-kit-vue3';
const {controller, create, dispose} = useAaaSPilotKit();
// Manually control lifecycle
const restartSession = async () => {
dispose();
await nextTick();
create();
};
</script>
Complete Example
View detailed usage examples and best practices:
- Installation and Quick Start - Detailed installation configuration and usage examples
- Provider Context - Dependency injection and Provider detailed configuration
- Composables API - All Composables detailed reference documentation
- FAQ - Common questions, best practices, and performance optimization
Technical Support
- Core library documentation: Vanilla SDK
- React version: React SDK
- Email support: zhangwenxi@baidu.com, lifuxin@baidu.com, hanbowen01@baidu.com