-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Add sample app for bidirectional streaming #2716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -24,5 +24,9 @@ | |||
</intent-filter> | |||
</activity> | |||
</application> | |||
<uses-permission android:name="android.permission.INTERNET" /> |
There was a problem hiding this comment.
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" + |
There was a problem hiding this comment.
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 { | |||
) | |||
) | |||
} | |||
|
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 (!!)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sure
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