Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.3.4

- Added `onServerMessage` callback

# 0.3.3

- Made `timestamp` and `userId` fields optional in `Transcript`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pipecat-client-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ publishing {
register<MavenPublication>("release") {
groupId = "ai.pipecat"
artifactId = "client"
version = "0.3.3"
version = "0.3.4"

pom {
name.set("Pipecat Client")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ open class RTVIClient(
callbacks.onStorageItemStored(data)
}

MsgServerToClient.Type.ServerMessage -> {
callbacks.onServerMessage(JSON_INSTANCE.decodeFromJsonElement(msg.data))
}

else -> {

var match = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down