diff --git a/CHANGELOG.md b/CHANGELOG.md index e132bb8..28caa31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.3.4 + +- Added `onServerMessage` callback + # 0.3.3 - Made `timestamp` and `userId` fields optional in `Transcript` diff --git a/README.md b/README.md index c046e94..02c1ffc 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ packages.) The base `RTVIClient` has no transport included. Add the following dependency to your `build.gradle` file: ``` -implementation "ai.pipecat:client:0.3.3" +implementation "ai.pipecat:client:0.3.4" ``` Then instantiate the `RTVIClient` from your code, specifying the backend `baseUrl` and transport. diff --git a/pipecat-client-android/build.gradle.kts b/pipecat-client-android/build.gradle.kts index 53a995b..b45e1c2 100644 --- a/pipecat-client-android/build.gradle.kts +++ b/pipecat-client-android/build.gradle.kts @@ -60,7 +60,7 @@ publishing { register("release") { groupId = "ai.pipecat" artifactId = "client" - version = "0.3.3" + version = "0.3.4" pom { name.set("Pipecat Client") diff --git a/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIClient.kt b/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIClient.kt index 0030df6..a9ba39e 100644 --- a/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIClient.kt +++ b/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIClient.kt @@ -213,6 +213,10 @@ open class RTVIClient( callbacks.onStorageItemStored(data) } + MsgServerToClient.Type.ServerMessage -> { + callbacks.onServerMessage(JSON_INSTANCE.decodeFromJsonElement(msg.data)) + } + else -> { var match = false diff --git a/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIEventCallbacks.kt b/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIEventCallbacks.kt index b3c8253..01664b6 100644 --- a/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIEventCallbacks.kt +++ b/pipecat-client-android/src/main/java/ai/pipecat/client/RTVIEventCallbacks.kt @@ -8,6 +8,7 @@ import ai.pipecat.client.types.ServiceConfig import ai.pipecat.client.types.Tracks import ai.pipecat.client.types.Transcript import ai.pipecat.client.types.TransportState +import ai.pipecat.client.types.Value /** * Callbacks invoked when changes occur in the RTVI session. @@ -168,6 +169,11 @@ abstract class RTVIEventCallbacks { * Invoked when data is stored by the bot. */ open fun onStorageItemStored(data: MsgServerToClient.Data.StorageItemStoredData) {} + + /** + * Invoked when we receive a server message from the bot. + */ + open fun onServerMessage(data: Value) {} } internal class CallbackInterceptor(vararg listeners: RTVIEventCallbacks): RTVIEventCallbacks() { @@ -269,4 +275,36 @@ internal class CallbackInterceptor(vararg listeners: RTVIEventCallbacks): RTVIEv override fun onTracksUpdated(tracks: Tracks) { callbacks.forEach { it.onTracksUpdated(tracks) } } + + override fun onBotLLMText(data: MsgServerToClient.Data.BotLLMTextData) { + callbacks.forEach { it.onBotLLMText(data) } + } + + override fun onBotTTSText(data: MsgServerToClient.Data.BotTTSTextData) { + callbacks.forEach { it.onBotTTSText(data) } + } + + override fun onBotLLMStarted() { + callbacks.forEach(RTVIEventCallbacks::onBotLLMStarted) + } + + override fun onBotLLMStopped() { + callbacks.forEach(RTVIEventCallbacks::onBotLLMStopped) + } + + override fun onBotTTSStarted() { + callbacks.forEach(RTVIEventCallbacks::onBotTTSStarted) + } + + override fun onBotTTSStopped() { + callbacks.forEach(RTVIEventCallbacks::onBotTTSStopped) + } + + override fun onStorageItemStored(data: MsgServerToClient.Data.StorageItemStoredData) { + callbacks.forEach { it.onStorageItemStored(data) } + } + + override fun onServerMessage(data: Value) { + callbacks.forEach { it.onServerMessage(data) } + } } \ No newline at end of file diff --git a/pipecat-client-android/src/main/java/ai/pipecat/client/transport/MsgServerToClient.kt b/pipecat-client-android/src/main/java/ai/pipecat/client/transport/MsgServerToClient.kt index 6717a02..2abbb4e 100644 --- a/pipecat-client-android/src/main/java/ai/pipecat/client/transport/MsgServerToClient.kt +++ b/pipecat-client-android/src/main/java/ai/pipecat/client/transport/MsgServerToClient.kt @@ -34,6 +34,7 @@ data class MsgServerToClient( const val BotStartedSpeaking = "bot-started-speaking" const val BotStoppedSpeaking = "bot-stopped-speaking" const val Config = "config" + const val ServerMessage = "server-message" // Service-specific const val BotLlmText = "bot-llm-text" // Streaming chunk/word, directly after LLM