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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 1.0.2

- Added new `sendText()` method to support the new RTVI `send-text` event. The method
takes a string, along with an optional set of options to control whether the bot
should respond immediately and/or whether the bot should respond with audio (vs. text only).
Note: This is a replacement for the current `appendToContext()` method.

- `appendToContext()` has been deprecated in favor of the new `sendText()` method.

# 1.0.1

- Changed content type `startBot()` POST request for compatibility reasons
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 = "1.0.1"
version = "1.0.2"

pom {
name.set("Pipecat Client")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ai.pipecat.client.types.LLMFunctionCallData
import ai.pipecat.client.types.LLMFunctionCallHandler
import ai.pipecat.client.types.LLMFunctionCallResult
import ai.pipecat.client.types.MediaDeviceId
import ai.pipecat.client.types.SendTextOptions
import ai.pipecat.client.types.Transcript
import ai.pipecat.client.types.TransportState
import ai.pipecat.client.types.Value
Expand Down Expand Up @@ -393,7 +394,10 @@ open class PipecatClient<TransportType : Transport<ConnectParams>, ConnectParams
*
* The context message becomes part of the LLM's memory for the current session and will be
* considered when generating future responses.
*
* Note: this method is deprecated. Use sendText() instead.
*/
@Deprecated("appendToContext() is deprecated. Use sendText() instead.")
fun appendToContext(
message: LLMContextMessage
): Future<AppendToContextResultData, RTVIError> = thread.runOnThreadReturningFuture {
Expand All @@ -408,6 +412,21 @@ open class PipecatClient<TransportType : Transport<ConnectParams>, ConnectParams
.mapToResult { catchExceptions { JSON_INSTANCE.decodeFromJsonElement(it) } }
}

/**
* Appends the specified message to the active conversation with the bot.
*
* The bot's response may be controlled using the values in `SendTextOptions`.
*/
fun sendText(
content: String,
options: SendTextOptions = SendTextOptions()
): Future<Unit, RTVIError> {
return sendMessage(MsgClientToServer.SendText(
content = content,
options = options
))
}

/**
* Registers a function call handler for a specific function name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ai.pipecat.client.transport
import ai.pipecat.client.types.DataMessage
import ai.pipecat.client.types.LLMContextMessage
import ai.pipecat.client.types.LLMFunctionCallResult
import ai.pipecat.client.types.SendTextOptions
import ai.pipecat.client.utils.JSON_INSTANCE
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -39,6 +40,7 @@ data class MsgClientToServer private constructor(
const val DisconnectBot = "disconnect-bot"
const val ClientMessage = "client-message"
const val AppendToContext = "append-to-context"
const val SendText = "send-text"
const val LlmFunctionCallResult = "llm-function-call-result"
}

Expand All @@ -58,6 +60,12 @@ data class MsgClientToServer private constructor(
@SerialName("platform_version")
val platformVersion: String
)

@Serializable
data class SendText(
val content: String,
val options: SendTextOptions
)
}

companion object {
Expand Down Expand Up @@ -106,6 +114,17 @@ data class MsgClientToServer private constructor(
data = JSON_INSTANCE.encodeToJsonElement(LLMContextMessage.serializer(), msg)
)

fun SendText(
content: String,
options: SendTextOptions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be marked optional in some way? (i have to admit, i don't fully understand the difference/relationship between this method and the one above in the client)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is just an internal method which builds the Data.SendText object, rather than a public API. The API function has the default value:

options: SendTextOptions = SendTextOptions()

) = MsgClientToServer(
type = Type.SendText,
data = JSON_INSTANCE.encodeToJsonElement(Data.SendText.serializer(), Data.SendText(
content = content,
options = options
))
)

fun DisconnectBot() = MsgClientToServer(
type = Type.DisconnectBot,
data = null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ai.pipecat.client.types

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class SendTextOptions(
@SerialName("run_immediately")
val runImmediately: Boolean? = null,
@SerialName("audio_response")
val audioResponse: Boolean? = null,
)