-
Notifications
You must be signed in to change notification settings - Fork 62
Reorganize some files #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e982021
93d9ade
8e1cef6
a5aa887
90b0835
8489679
1f1ad8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,7 +126,7 @@ final class WebRTCConnectionManager: WebRTCConnectionManaging { | |
| switch await waitForAgentReady(timeout: agentTimeout) { | ||
| case let .success(elapsed): | ||
| metrics.agentReady = elapsed | ||
| onStartupStateChange(.agentReady(ConversationAgentReadyReport(elapsed: elapsed))) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary wrapper class with a single field |
||
| onStartupStateChange(.agentReady(elapsed: elapsed)) | ||
| case let .timedOut(elapsed): | ||
| metrics.agentReady = elapsed | ||
| metrics.total = Date().timeIntervalSince(startTime) | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| /// Reason for the conversation disconnection | ||
| public enum DisconnectionReason: Sendable { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deleted - we already have |
||
| case agent | ||
| case user | ||
| case error | ||
| } | ||
|
|
||
| /// Main configuration for a conversation session | ||
| public struct ConversationConfig: Sendable { | ||
| public var agentOverrides: AgentOverrides? | ||
|
|
@@ -152,3 +145,119 @@ public struct Endpoints: Sendable, Equatable { | |
| apiBase.appendingPathComponent("v1/convai/conversation/token") | ||
| } | ||
| } | ||
|
|
||
| public struct ConversationStartupConfiguration: Sendable, Equatable { | ||
| public var agentReadyTimeout: TimeInterval | ||
| public var initiationMetadataTimeout: TimeInterval | ||
|
|
||
| public init( | ||
| agentReadyTimeout: TimeInterval = 3.0, | ||
| initiationMetadataTimeout: TimeInterval = 5.0 | ||
| ) { | ||
| self.agentReadyTimeout = agentReadyTimeout | ||
| self.initiationMetadataTimeout = initiationMetadataTimeout | ||
| } | ||
|
|
||
| public static let `default` = ConversationStartupConfiguration() | ||
| } | ||
|
|
||
| /// Controls how the SDK establishes WebRTC connections. | ||
| /// | ||
| /// The default configuration gathers all ICE candidate types. Use ``Strategy/relayOnly`` | ||
| /// to restrict connections to TURN relays. | ||
| public struct WebRTCConfiguration: Sendable { | ||
| /// Describes how ICE transport candidates should be gathered. | ||
| public enum Strategy: Sendable, Equatable { | ||
| /// Gather all candidate types. | ||
| case automatic | ||
| /// Force TURN relay candidates only. | ||
| case relayOnly | ||
| } | ||
|
|
||
| /// The strategy to use for ICE gathering. Defaults to ``Strategy/automatic``. | ||
| public var strategy: Strategy | ||
|
|
||
| public init(strategy: Strategy = .automatic) { | ||
| self.strategy = strategy | ||
| } | ||
|
|
||
| /// Default configuration using automatic ICE candidate gathering. | ||
| public static let `default` = WebRTCConfiguration() | ||
| } | ||
|
|
||
| /// Configuration for event-based agent state management using VAD and client events. | ||
| /// Pass `nil` to use the default LiveKit-based behaviour. | ||
| public struct AgentStateConfiguration: Sendable { | ||
| public var vadSpeakingThreshold: Double | ||
| public var minSpeechDuration: TimeInterval | ||
| public var minSilenceDuration: TimeInterval | ||
| public var speakingToListeningDelay: TimeInterval | ||
|
|
||
| public init( | ||
| vadSpeakingThreshold: Double = 0.5, | ||
| minSpeechDuration: TimeInterval = 0.15, | ||
| minSilenceDuration: TimeInterval = 0.05, | ||
| speakingToListeningDelay: TimeInterval = 0.5 | ||
| ) { | ||
| self.vadSpeakingThreshold = vadSpeakingThreshold | ||
| self.minSpeechDuration = minSpeechDuration | ||
| self.minSilenceDuration = minSilenceDuration | ||
| self.speakingToListeningDelay = speakingToListeningDelay | ||
| } | ||
|
|
||
| public static let `default` = AgentStateConfiguration() | ||
| } | ||
|
|
||
| /// Configures microphone pipeline and voice activity reporting exposed by the SDK. | ||
| public struct AudioPipelineConfiguration: Sendable { | ||
| /// Override the microphone mute strategy. Defaults to `.inputMixer` to match previous SDK behaviour. | ||
| public var microphoneMuteMode: MicrophoneMuteMode? | ||
|
|
||
| /// Keep the recording engine warm to avoid first-spoken-word latency. Defaults to `true`. | ||
| public var recordingAlwaysPrepared: Bool? | ||
|
|
||
| /// Bypass WebRTC voice processing (AEC/NS/VAD). Leave `nil` to preserve system defaults. | ||
| public var voiceProcessingBypassed: Bool? | ||
|
|
||
| /// Toggle Auto Gain Control. Leave `nil` to preserve system defaults. | ||
| public var voiceProcessingAGCEnabled: Bool? | ||
|
|
||
| public init( | ||
| microphoneMuteMode: MicrophoneMuteMode? = .inputMixer, | ||
| recordingAlwaysPrepared: Bool? = true, | ||
| voiceProcessingBypassed: Bool? = nil, | ||
| voiceProcessingAGCEnabled: Bool? = nil | ||
| ) { | ||
| self.microphoneMuteMode = microphoneMuteMode | ||
| self.recordingAlwaysPrepared = recordingAlwaysPrepared | ||
| self.voiceProcessingBypassed = voiceProcessingBypassed | ||
| self.voiceProcessingAGCEnabled = voiceProcessingAGCEnabled | ||
| } | ||
|
|
||
| public static let `default` = AudioPipelineConfiguration() | ||
| } | ||
|
|
||
| /// Strategy used when muting the local microphone. Exactly one strategy is active | ||
| /// at a time. | ||
| public enum MicrophoneMuteMode: Sendable, Equatable { | ||
| /// Mutes instantly by silencing the input mixer. The mic stays open and the | ||
| /// audio session remains active. Recommended default. | ||
| case inputMixer | ||
|
|
||
| /// Mutes by restarting the engine without mic input. Releases the mic, but | ||
| /// mute/unmute is slower and speech detection is unavailable. | ||
| case restart | ||
|
|
||
| /// Mutes the voice-processing input. Fast, supports | ||
| /// ``ConversationCallbacks/onSpeechDetectedWhileMuted``, and keeps the audio | ||
| /// session active. | ||
| case voiceProcessing | ||
|
|
||
| /// Mutes in software by zeroing captured audio before it leaves the device. | ||
| /// Supports ``ConversationCallbacks/onSpeechDetectedWhileMuted``. | ||
| /// | ||
| /// - Parameters: | ||
| /// - speechThreshold: dB threshold for muted-speech detection. | ||
| /// - notificationThrottle: Minimum interval between muted-speech callbacks. | ||
| case software(speechThreshold: Float = -35, notificationThrottle: TimeInterval = 3.0) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Foundation | ||
|
|
||
| /// Agent state indicating what the agent is currently doing. | ||
| public enum AgentState: Sendable, Equatable { | ||
| /// Agent is listening to the user | ||
| case listening | ||
| /// Agent is speaking | ||
| case speaking | ||
| /// Agent is thinking (e.g. preparing a tool call) | ||
| case thinking | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant, just one reason is enough