Overview
When you need to implement private Agent streaming API protocol integration, you can create a custom Agent service class by inheriting from BaseAgentService.
What is AgentService
AgentService is the core component for handling communication with AI conversation services, responsible for:
- Sending user messages to AI service endpoints
- Receiving and processing streaming response data
- Managing conversation session states
- Handling connection exceptions and retry logic
Core Features
1. Streaming Conversation Processing
Implement real-time conversation responses through SSE (Server-Sent Events) or WebSocket.
2. Session Management
Automatically maintain conversation session IDs to ensure continuity across multiple conversation rounds.
3. Error Handling
Provides complete error handling mechanisms, including network exceptions, server errors, etc.
4. Extensibility
Supports custom request parameters, response processing logic, and business-specific features.
Use Cases
- Integrate with privately deployed AI conversation services
- Scenarios requiring custom request/response formats
- Implement complex business logic processing
- Add custom monitoring and tracking
Configuration Notes
⚠️ Important: When using custom agentService, standard agentConfig configuration will not be available. All related configurations need to be implemented in the custom service class.
import {createAaaSPilotKit, BaseAgentService} from '@bdky/aaas-pilot-kit';
// Create custom AgentService
class CustomAgentService extends BaseAgentService {
// Implement specific logic
}
// Bind in Kit initialization, <CustomAgentService> TS generic parameter recommended for type constraint
const kit = createAaaSPilotKit<CustomAgentService>({
// Other configurations...
agentService: CustomAgentService
});
Next Steps
Choose the HTTP client implementation suitable for your project: