setupSession method
Future<void>
setupSession({
- required String systemInstruction,
- String voice = 'Kore',
- String language = 'en-US',
- InteractionMode mode = InteractionMode.audio,
Initializes a new session with the specified configuration
This method establishes the session parameters for AI communication. Must be called before sending any data.
Parameters:
systemInstruction: The system prompt that defines AI behaviorvoice: Voice name for speech synthesis (default: 'Kore')language: Language code for responses (default: 'en-US')mode: Interaction mode - audio or text (default: audio)
Implementation
Future<void> setupSession({
required String systemInstruction,
String voice = 'Kore',
String language = 'en-US',
InteractionMode mode = InteractionMode.audio,
}) async {
_interactionMode = mode;
if (mode == InteractionMode.audio) {
// Audio mode: Ensure connection is established
await _ensureConnected();
// Mark as ready for audio communication
} else {
// Text mode: Update connection state and mark as ready
_setConnectionState(WebSocketConnectionState.connected);
}
}