-
Notifications
You must be signed in to change notification settings - Fork 617
Davidmotson.firebase ai #6911
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
Merged
Merged
Davidmotson.firebase ai #6911
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5c22a5e
Copy vertexai to firebase-ai
a5a068f
revert changes to firebase-vertexai dir
40a16cc
add changes to match the new api spec, add imagen, and google-ai supp…
davidmotson c1c507f
remove unneeded diffs
4b505c1
Merge branch 'main' into davidmotson.firebase-ai
davidmotson df6a6ed
revert submodule updates
def369c
fix for jules
2915966
Update firebase-ai/lint-baseline.xml
davidmotson 8287ce2
Update firebase-ai/src/test/resources/README.md
davidmotson 8f05b13
Update firebase-ai/src/main/kotlin/com/google/firebase/ai/FirebaseAIM…
davidmotson 5d1a95c
Update firebase-ai/src/main/kotlin/com/google/firebase/ai/FirebaseAI.kt
davidmotson 197b090
Merge branch 'main' into davidmotson.firebase-ai
davidmotson 268bcca
[ai] Address most tests failures (#6915)
rlazo 318feaa
remove test that keeps timing out
3fdd552
format
bffe50a
re-add fixed test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Unreleased | ||
* [changed] **Breaking Change**: `LiveModelFutures.connect` now returns `ListenableFuture<LiveSessionFutures>` instead of `ListenableFuture<LiveSession>`. | ||
* **Action Required:** Remove any transformations from LiveSession object to LiveSessionFutures object. | ||
* **Action Required:** Change type of variable handling `LiveModelFutures.connect` to `ListenableFuture<LiveSessionsFutures>` | ||
* [changed] **Breaking Change**: Removed `UNSPECIFIED` value for enum class `ResponseModality` | ||
* **Action Required:** Remove all references to `ResponseModality.UNSPECIFIED` | ||
* [changed] **Breaking Change**: Renamed `LiveGenerationConfig.setResponseModalities` to `LiveGenerationConfig.setResponseModality` | ||
* **Action Required:** Replace all references of `LiveGenerationConfig.setResponseModalities` with `LiveGenerationConfig.setResponseModality` | ||
* [feature] Added support for `HarmBlockThreshold.OFF`. See the | ||
[model documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters#how_to_configure_content_filters){: .external} | ||
for more information. | ||
* [fixed] Improved thread usage when using a `LiveGenerativeModel`. (#6870) | ||
* [fixed] Fixed an issue with `LiveContentResponse` audio data not being present when the model was | ||
interrupted or the turn completed. (#6870) | ||
* [fixed] Fixed an issue with `LiveSession` not converting exceptions to `FirebaseVertexAIException`. (#6870) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Firebase AI SDK | ||
|
||
For developer documentation, please visit https://firebase.google.com/docs/vertex-ai. | ||
This README is for contributors building and running tests for the SDK. | ||
|
||
## Building | ||
|
||
All Gradle commands should be run from the root of this repository. | ||
|
||
`./gradlew :firebase-ai:publishToMavenLocal` | ||
|
||
## Running Tests | ||
|
||
> [!IMPORTANT] | ||
> These unit tests require mock response files, which can be downloaded by running | ||
`./firebase-ai/update_responses.sh` from the root of this repository. | ||
|
||
Unit tests: | ||
|
||
`./gradlew :firebase-ai:check` | ||
|
||
Integration tests, requiring a running and connected device (emulator or real): | ||
|
||
`./gradlew :firebase-ai:deviceCheck` | ||
|
||
## Code Formatting | ||
|
||
Format Kotlin code in this SDK in Android Studio using | ||
the [spotless plugin]([https://plugins.jetbrains.com/plugin/14912-ktfmt](https://github.com/diffplug/spotless) | ||
by running: | ||
|
||
`./gradlew firebase-ai:spotlessApply` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile | ||
|
||
-keep class com.google.firebase.ai.type.** { *; } | ||
-keep class com.google.firebase.ai.common.** { *; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
@file:Suppress("UnstableApiUsage") | ||
|
||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("firebase-library") | ||
id("kotlin-android") | ||
alias(libs.plugins.kotlinx.serialization) | ||
} | ||
|
||
firebaseLibrary { | ||
testLab.enabled = false | ||
publishJavadoc = true | ||
releaseNotes { | ||
name.set("{{firebase_ai}}") | ||
versionName.set("ai") | ||
hasKTX.set(false) | ||
} | ||
} | ||
|
||
android { | ||
val targetSdkVersion: Int by rootProject | ||
|
||
namespace = "com.google.firebase.ai" | ||
compileSdk = 34 | ||
defaultConfig { | ||
minSdk = 21 | ||
consumerProguardFiles("consumer-rules.pro") | ||
multiDexEnabled = true | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { jvmTarget = "1.8" } | ||
testOptions { | ||
targetSdk = targetSdkVersion | ||
unitTests { | ||
isIncludeAndroidResources = true | ||
isReturnDefaultValues = true | ||
} | ||
} | ||
lint { | ||
targetSdk = targetSdkVersion | ||
baseline = file("lint-baseline.xml") | ||
} | ||
sourceSets { getByName("test").java.srcDirs("src/testUtil") } | ||
} | ||
|
||
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any | ||
// classes, methods, or properties have implicit `public` visibility. This check helps | ||
// avoid accidentally leaking elements into the public API, requiring that any public | ||
// element be explicitly declared as `public`. | ||
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md | ||
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1 | ||
tasks.withType<KotlinCompile>().all { | ||
if (!name.contains("test", ignoreCase = true)) { | ||
if (!kotlinOptions.freeCompilerArgs.contains("-Xexplicit-api=strict")) { | ||
kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.ktor.client.okhttp) | ||
implementation(libs.ktor.client.core) | ||
implementation(libs.ktor.client.websockets) | ||
implementation(libs.ktor.client.content.negotiation) | ||
implementation(libs.ktor.serialization.kotlinx.json) | ||
implementation(libs.ktor.client.logging) | ||
|
||
api("com.google.firebase:firebase-common:21.0.0") | ||
implementation("com.google.firebase:firebase-components:18.0.0") | ||
implementation("com.google.firebase:firebase-annotations:16.2.0") | ||
implementation("com.google.firebase:firebase-appcheck-interop:17.1.0") | ||
implementation(libs.androidx.annotation) | ||
implementation(libs.kotlinx.serialization.json) | ||
implementation(libs.androidx.core.ktx) | ||
implementation(libs.slf4j.nop) | ||
implementation(libs.kotlinx.coroutines.android) | ||
implementation(libs.kotlinx.coroutines.reactive) | ||
implementation(libs.reactive.streams) | ||
implementation("com.google.guava:listenablefuture:1.0") | ||
implementation("androidx.concurrent:concurrent-futures:1.2.0") | ||
implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0") | ||
implementation("com.google.firebase:firebase-auth-interop:18.0.0") | ||
|
||
testImplementation(libs.kotest.assertions.core) | ||
testImplementation(libs.kotest.assertions) | ||
testImplementation(libs.kotest.assertions.json) | ||
testImplementation(libs.ktor.client.okhttp) | ||
testImplementation(libs.ktor.client.mock) | ||
testImplementation(libs.org.json) | ||
testImplementation(libs.androidx.test.junit) | ||
testImplementation(libs.androidx.test.runner) | ||
testImplementation(libs.junit) | ||
testImplementation(libs.kotlin.coroutines.test) | ||
testImplementation(libs.robolectric) | ||
testImplementation(libs.truth) | ||
testImplementation(libs.mockito.core) | ||
|
||
androidTestImplementation(libs.androidx.espresso.core) | ||
androidTestImplementation(libs.androidx.test.junit) | ||
androidTestImplementation(libs.androidx.test.runner) | ||
androidTestImplementation(libs.truth) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
version=16.0.0 | ||
latestReleasedVersion= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2025 Google LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<issues format="6" by="lint 8.3.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.2)" variant="all" version="8.3.2"> | ||
|
||
<issue | ||
id="MissingPermission" | ||
message="Missing permissions required by AudioHelper.startRecording: android.permission.RECORD_AUDIO" | ||
errorLine1=" CoroutineScope(backgroundDispatcher).launch {" | ||
errorLine2=" ^"> | ||
<location | ||
file="src/main/kotlin/com/google/firebase/vertexai/type/LiveSession.kt" | ||
line="133" | ||
column="42"/> | ||
</issue> | ||
|
||
</issues> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2024 Google LLC --> | ||
<!-- --> | ||
<!-- Licensed under the Apache License, Version 2.0 (the "License"); --> | ||
<!-- you may not use this file except in compliance with the License. --> | ||
<!-- You may obtain a copy of the License at --> | ||
<!-- --> | ||
<!-- http://www.apache.org/licenses/LICENSE-2.0 --> | ||
<!-- --> | ||
<!-- Unless required by applicable law or agreed to in writing, software --> | ||
<!-- distributed under the License is distributed on an "AS IS" BASIS, --> | ||
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> | ||
<!-- See the License for the specific language governing permissions and --> | ||
<!-- limitations under the License. --> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<!--Although the *SdkVersion is captured in gradle build files, this is required for non gradle builds--> | ||
<!--<uses-sdk android:minSdkVersion="21"/>--> | ||
|
||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<!-- To use the audio conversation feature of Live Sessions, update your app's manifest --> | ||
<!-- to request audio recording permission --> | ||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> --> | ||
|
||
<application> | ||
<service android:name="com.google.firebase.components.ComponentDiscoveryService" | ||
android:exported="false"> | ||
<meta-data | ||
android:name="com.google.firebase.components:com.google.firebase.ai.FirebaseAIRegistrar" | ||
android:value="com.google.firebase.components.ComponentRegistrar" /> | ||
</service> | ||
</application> | ||
</manifest> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.