Skip to content

Commit

Permalink
Renaming PipecatClient back to RTVIClient
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-daily committed Dec 11, 2024
1 parent 579b570 commit 78a0aec
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# 0.3.0

- Project renamed to `pipecat-client-android`
- `RTVIClient` renamed to `PipecatClient`

# 0.2.1

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This Android library contains the core components and types needed to set up an

When building an RTVI application, you should use the transport-specific client library (see
[here](https://rtvi.mintlify.app/api-reference/transports/introduction) for available first-party
packages.) The base `PipecatClient` has no transport included.
packages.) The base `RTVIClient` has no transport included.

## Usage

Expand All @@ -16,7 +16,7 @@ Add the following dependency to your `build.gradle` file:
implementation "ai.pipecat:client:0.3.0"
```

Then instantiate the `PipecatClient` from your code, specifying the backend `baseUrl` and transport.
Then instantiate the `RTVIClient` from your code, specifying the backend `baseUrl` and transport.

```kotlin
val callbacks = object : RTVIEventCallbacks() {
Expand All @@ -28,7 +28,7 @@ val callbacks = object : RTVIEventCallbacks() {
// ...
}

val client = PipecatClient(transport, callbacks, options)
val client = RTVIClient(transport, callbacks, options)

client.start().withCallback {
// ...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ai.pipecat.client

import ai.pipecat.client.helper.RTVIClientHelper
import ai.pipecat.client.helper.RegisteredPipecatClient
import ai.pipecat.client.helper.RegisteredRTVIClient
import ai.pipecat.client.result.Future
import ai.pipecat.client.result.Promise
import ai.pipecat.client.result.RTVIError
Expand Down Expand Up @@ -53,7 +53,7 @@ private const val RTVI_PROTOCOL_VERSION = "0.3.0"
* @param options Additional options for configuring the client and backend.
*/
@Suppress("unused")
open class PipecatClient(
open class RTVIClient(
transport: TransportFactory,
callbacks: RTVIEventCallbacks,
private var options: RTVIClientOptions,
Expand Down Expand Up @@ -101,12 +101,12 @@ open class PipecatClient(
private val transportCtx = object : TransportContext {

override val options
get() = this@PipecatClient.options
get() = this@RTVIClient.options

override val callbacks
get() = this@PipecatClient.callbacks
get() = this@RTVIClient.callbacks

override val thread = this@PipecatClient.thread
override val thread = this@RTVIClient.thread

override fun onMessage(msg: MsgServerToClient) = thread.runOnThread {

Expand All @@ -117,7 +117,7 @@ open class PipecatClient(
val data =
JSON_INSTANCE.decodeFromJsonElement<MsgServerToClient.Data.BotReady>(msg.data)

this@PipecatClient.transport.setState(TransportState.Ready)
this@RTVIClient.transport.setState(TransportState.Ready)

connection?.ready?.resolveOk(Unit)

Expand Down Expand Up @@ -345,7 +345,7 @@ open class PipecatClient(
throw RTVIException(RTVIError.OtherError("Helper targeting service '$service' already registered"))
}

helper.registerVoiceClient(RegisteredPipecatClient(this, service))
helper.registerVoiceClient(RegisteredRTVIClient(this, service))

val entry = RegisteredHelper(
helper = helper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private fun Value.asJsonElement(): JsonElement = when (this) {
Value.Null -> JsonNull
}

private fun <V> RegisteredPipecatClient.ensureReady(action: () -> Future<V, RTVIError>): Future<V, RTVIError> =
private fun <V> RegisteredRTVIClient.ensureReady(action: () -> Future<V, RTVIError>): Future<V, RTVIError> =
if (client.state == TransportState.Ready) {
action()
} else {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ai.pipecat.client.helper

import ai.pipecat.client.PipecatClient
import ai.pipecat.client.RTVIClient
import ai.pipecat.client.result.Future
import ai.pipecat.client.result.RTVIError
import ai.pipecat.client.result.RTVIException
Expand All @@ -12,10 +12,10 @@ import java.util.concurrent.atomic.AtomicReference

abstract class RTVIClientHelper {

private val voiceClient = AtomicReference<RegisteredPipecatClient?>(null)
private val voiceClient = AtomicReference<RegisteredRTVIClient?>(null)

protected fun <R> withClient(
action: (RegisteredPipecatClient) -> Future<R, RTVIError>
action: (RegisteredRTVIClient) -> Future<R, RTVIError>
): Future<R, RTVIError> {

val client = voiceClient.get() ?: return resolvedPromiseErr(
Expand All @@ -26,7 +26,7 @@ abstract class RTVIClientHelper {
return client.client.thread.runOnThreadReturningFuture { action(client) }
}

protected val client: RegisteredPipecatClient?
protected val client: RegisteredRTVIClient?
get() = voiceClient.get()

/**
Expand All @@ -41,7 +41,7 @@ abstract class RTVIClientHelper {
abstract fun getMessageTypes(): Set<String>

@Throws(RTVIException::class)
internal fun registerVoiceClient(client: RegisteredPipecatClient) {
internal fun registerVoiceClient(client: RegisteredRTVIClient) {
if (!this.voiceClient.compareAndSet(null, client)) {
throw RTVIException(RTVIError.OtherError("Helper is already registered to a client"))
}
Expand All @@ -55,8 +55,8 @@ abstract class RTVIClientHelper {
}
}

class RegisteredPipecatClient(
val client: PipecatClient,
class RegisteredRTVIClient(
val client: RTVIClient,
val service: String,
) {
fun action(action: String, args: List<Option> = emptyList()) =
Expand Down

0 comments on commit 78a0aec

Please sign in to comment.