Merge pull request #955 from pipecat-ai/ios-simple-chatbot-mainactor-fixes

iOS SimpleChatbot @MainActor fixes
This commit is contained in:
kompfner
2025-01-10 09:37:02 -05:00
committed by GitHub
3 changed files with 49 additions and 31 deletions

View File

@@ -684,10 +684,10 @@
/* Begin XCRemoteSwiftPackageReference section */ /* Begin XCRemoteSwiftPackageReference section */
90B6AB2F2D1359ED00DFF1D9 /* XCRemoteSwiftPackageReference "pipecat-client-ios-daily" */ = { 90B6AB2F2D1359ED00DFF1D9 /* XCRemoteSwiftPackageReference "pipecat-client-ios-daily" */ = {
isa = XCRemoteSwiftPackageReference; isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pipecat-ai/pipecat-client-ios-daily/"; repositoryURL = "https://github.com/pipecat-ai/pipecat-client-ios-daily";
requirement = { requirement = {
kind = upToNextMajorVersion; kind = upToNextMajorVersion;
minimumVersion = 0.3.0; minimumVersion = 0.3.1;
}; };
}; };
/* End XCRemoteSwiftPackageReference section */ /* End XCRemoteSwiftPackageReference section */

View File

@@ -1,5 +1,5 @@
{ {
"originHash" : "cc17f08b06def9570d775e9c6f7a8dc10d1588b98127e977c47d052abac659b7", "originHash" : "72945fe9f3d71a3b546d5d2df153345b4dc9e72c00b2fda349508223e1a88501",
"pins" : [ "pins" : [
{ {
"identity" : "daily-client-ios", "identity" : "daily-client-ios",
@@ -15,17 +15,17 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/pipecat-ai/pipecat-client-ios.git", "location" : "https://github.com/pipecat-ai/pipecat-client-ios.git",
"state" : { "state" : {
"revision" : "fd8418559b6f885af7662b78fabdb0e2f08fbb1a", "revision" : "d2d9946cf93f1e89290c724caa1631cffa439524",
"version" : "0.3.0" "version" : "0.3.1"
} }
}, },
{ {
"identity" : "pipecat-client-ios-daily", "identity" : "pipecat-client-ios-daily",
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/pipecat-ai/pipecat-client-ios-daily/", "location" : "https://github.com/pipecat-ai/pipecat-client-ios-daily",
"state" : { "state" : {
"revision" : "03e1d1da973fb1aab65ac0c8267664f334a74c50", "revision" : "cec4beef8762604c9a9b5ec760081ea2a0a697bf",
"version" : "0.3.0" "version" : "0.3.1"
} }
} }
], ],

View File

@@ -127,55 +127,73 @@ extension CallContainerModel:RTVIClientDelegate, LLMHelperDelegate {
} }
func onTransportStateChanged(state: TransportState) { func onTransportStateChanged(state: TransportState) {
self.handleEvent(eventName: "onTransportStateChanged", eventValue: state) Task { @MainActor in
self.voiceClientStatus = state.description self.handleEvent(eventName: "onTransportStateChanged", eventValue: state)
self.isInCall = ( state == .connecting || state == .connected || state == .ready || state == .authenticating ) self.voiceClientStatus = state.description
} self.isInCall = ( state == .connecting || state == .connected || state == .ready || state == .authenticating )
}
@MainActor }
func onBotReady(botReadyData: BotReadyData) {
self.handleEvent(eventName: "onBotReady.") func onBotReady(botReadyData: BotReadyData) {
self.isBotReady = true Task { @MainActor in
if let expirationTime = self.rtviClientIOS?.expiry() { self.handleEvent(eventName: "onBotReady.")
self.startTimer(withExpirationTime: expirationTime) self.isBotReady = true
if let expirationTime = self.rtviClientIOS?.expiry() {
self.startTimer(withExpirationTime: expirationTime)
}
} }
} }
@MainActor
func onConnected() { func onConnected() {
self.isMicEnabled = self.rtviClientIOS?.isMicEnabled ?? false Task { @MainActor in
self.isMicEnabled = self.rtviClientIOS?.isMicEnabled ?? false
}
} }
func onDisconnected() { func onDisconnected() {
self.stopTimer() Task { @MainActor in
self.isBotReady = false self.stopTimer()
self.isBotReady = false
}
} }
func onRemoteAudioLevel(level: Float, participant: Participant) { func onRemoteAudioLevel(level: Float, participant: Participant) {
self.remoteAudioLevel = level Task { @MainActor in
self.remoteAudioLevel = level
}
} }
func onUserAudioLevel(level: Float) { func onUserAudioLevel(level: Float) {
self.localAudioLevel = level Task { @MainActor in
self.localAudioLevel = level
}
} }
func onUserTranscript(data: Transcript) { func onUserTranscript(data: Transcript) {
if (data.final ?? false) { Task { @MainActor in
self.handleEvent(eventName: "onUserTranscript", eventValue: data.text) if (data.final ?? false) {
self.handleEvent(eventName: "onUserTranscript", eventValue: data.text)
}
} }
} }
func onBotTranscript(data: String) { func onBotTranscript(data: String) {
self.handleEvent(eventName: "onBotTranscript", eventValue: data) Task { @MainActor in
self.handleEvent(eventName: "onBotTranscript", eventValue: data)
}
} }
func onError(message: String) { func onError(message: String) {
self.handleEvent(eventName: "onError", eventValue: message) Task { @MainActor in
self.showError(message: message) self.handleEvent(eventName: "onError", eventValue: message)
self.showError(message: message)
}
} }
func onTracksUpdated(tracks: Tracks) { func onTracksUpdated(tracks: Tracks) {
self.handleEvent(eventName: "onTracksUpdated", eventValue: tracks) Task { @MainActor in
self.handleEvent(eventName: "onTracksUpdated", eventValue: tracks)
}
} }
} }