Skip to content

Conversation

VinayGuthal
Copy link

@VinayGuthal VinayGuthal commented Aug 26, 2025

This PR adds a sample app for bidirectional streaming. The sample app also has inbuilt function calling allowing users to use function calling along with bidi.
The image of the app is as below
Screenshot 2025-08-26 at 2 21 13 PM

@VinayGuthal VinayGuthal changed the title Add bidi sample app Add sample app for bidirectional streaming Aug 26, 2025
@@ -24,5 +24,9 @@
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: move permissions before application

@@ -270,6 +270,34 @@ val FIREBASE_AI_SAMPLES = listOf(
)
}
),
Sample(
title = "Converse With AI",
description = "Simple app which allows you to talk to AI and" +
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a feature within the "app"

@@ -24,5 +24,6 @@ class WeatherRepository {
)
)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

revert

@@ -21,6 +21,7 @@ enum class Category(
AUDIO("Audio"),
DOCUMENT("Document"),
FUNCTION_CALLING("Function calling"),
LIVE_API("Bidi Streaming")
Copy link
Contributor

Choose a reason for hiding this comment

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

LiveAPI Streaming

)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = "Tap the end button to stop", // Example timer
Copy link
Contributor

Choose a reason for hiding this comment

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

timer?

val liveGenerationConfig = liveGenerationConfig {
speechConfig = SpeechConfig(voice = Voice("CHARON"))
responseModality = ResponseModality.AUDIO
// Change this to ContentModality.TEXT if you want text output.
Copy link
Contributor

Choose a reason for hiding this comment

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

comment first, code second

}
@OptIn(PublicPreviewAPI::class)
val liveModel = FirebaseAI.getInstance(Firebase.app, sample.backend).liveModel(
"gemini-live-2.5-flash-preview",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work with preview?

Copy link
Author

Choose a reason for hiding this comment

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

yes if it's google ai. I can just change it to flash

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 lets change it

val response:JsonObject
fetchWeatherCall.let {
val city = it.args["city"]!!.jsonPrimitive.content
val state = it.args["city"]!!.jsonPrimitive.content
Copy link
Contributor

Choose a reason for hiding this comment

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

city twice

fun handler(fetchWeatherCall: FunctionCallPart) : FunctionResponsePart {
val response:JsonObject
fetchWeatherCall.let {
val city = it.args["city"]!!.jsonPrimitive.content
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you handle more gracefully the check instead of using (!!)?

Copy link
Author

Choose a reason for hiding this comment

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

yes sure

@firebase firebase deleted a comment from chelsiemclellan10-ux Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants