Skip to content

Commit 7cbb80b

Browse files
davidmotsonDavid Motsonashvili
and
David Motsonashvili
authored
Davidmotson.firebase ai (#6911)
Co-authored-by: David Motsonashvili <[email protected]>
1 parent b4a2197 commit 7cbb80b

File tree

93 files changed

+11102
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+11102
-1
lines changed

.github/workflows/ci_tests.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ jobs:
5656
distribution: temurin
5757
cache: gradle
5858

59-
- name: Clone mock responses
59+
- name: Clone vertexai mock responses
6060
if: matrix.module == ':firebase-vertexai'
6161
run: firebase-vertexai/update_responses.sh
6262

63+
- name: Clone ai mock responses
64+
if: matrix.module == ':firebase-ai'
65+
run: firebase-ai/update_responses.sh
66+
6367
- name: Add google-services.json
6468
env:
6569
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}

firebase-ai/CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Unreleased
2+
* [changed] **Breaking Change**: `LiveModelFutures.connect` now returns `ListenableFuture<LiveSessionFutures>` instead of `ListenableFuture<LiveSession>`.
3+
* **Action Required:** Remove any transformations from LiveSession object to LiveSessionFutures object.
4+
* **Action Required:** Change type of variable handling `LiveModelFutures.connect` to `ListenableFuture<LiveSessionsFutures>`
5+
* [changed] **Breaking Change**: Removed `UNSPECIFIED` value for enum class `ResponseModality`
6+
* **Action Required:** Remove all references to `ResponseModality.UNSPECIFIED`
7+
* [changed] **Breaking Change**: Renamed `LiveGenerationConfig.setResponseModalities` to `LiveGenerationConfig.setResponseModality`
8+
* **Action Required:** Replace all references of `LiveGenerationConfig.setResponseModalities` with `LiveGenerationConfig.setResponseModality`
9+
* [feature] Added support for `HarmBlockThreshold.OFF`. See the
10+
[model documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters#how_to_configure_content_filters){: .external}
11+
for more information.
12+
* [fixed] Improved thread usage when using a `LiveGenerativeModel`. (#6870)
13+
* [fixed] Fixed an issue with `LiveContentResponse` audio data not being present when the model was
14+
interrupted or the turn completed. (#6870)
15+
* [fixed] Fixed an issue with `LiveSession` not converting exceptions to `FirebaseVertexAIException`. (#6870)

firebase-ai/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Firebase AI SDK
2+
3+
For developer documentation, please visit https://firebase.google.com/docs/vertex-ai.
4+
This README is for contributors building and running tests for the SDK.
5+
6+
## Building
7+
8+
All Gradle commands should be run from the root of this repository.
9+
10+
`./gradlew :firebase-ai:publishToMavenLocal`
11+
12+
## Running Tests
13+
14+
> [!IMPORTANT]
15+
> These unit tests require mock response files, which can be downloaded by running
16+
`./firebase-ai/update_responses.sh` from the root of this repository.
17+
18+
Unit tests:
19+
20+
`./gradlew :firebase-ai:check`
21+
22+
Integration tests, requiring a running and connected device (emulator or real):
23+
24+
`./gradlew :firebase-ai:deviceCheck`
25+
26+
## Code Formatting
27+
28+
Format Kotlin code in this SDK in Android Studio using
29+
the [spotless plugin]([https://plugins.jetbrains.com/plugin/14912-ktfmt](https://github.com/diffplug/spotless)
30+
by running:
31+
32+
`./gradlew firebase-ai:spotlessApply`

firebase-ai/api.txt

+908
Large diffs are not rendered by default.

firebase-ai/consumer-rules.pro

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
23+
-keep class com.google.firebase.ai.type.** { *; }
24+
-keep class com.google.firebase.ai.common.** { *; }

firebase-ai/firebase-ai.gradle.kts

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@file:Suppress("UnstableApiUsage")
18+
19+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
20+
21+
plugins {
22+
id("firebase-library")
23+
id("kotlin-android")
24+
alias(libs.plugins.kotlinx.serialization)
25+
}
26+
27+
firebaseLibrary {
28+
testLab.enabled = false
29+
publishJavadoc = true
30+
releaseNotes {
31+
name.set("{{firebase_ai}}")
32+
versionName.set("ai")
33+
hasKTX.set(false)
34+
}
35+
}
36+
37+
android {
38+
val targetSdkVersion: Int by rootProject
39+
40+
namespace = "com.google.firebase.ai"
41+
compileSdk = 34
42+
defaultConfig {
43+
minSdk = 21
44+
consumerProguardFiles("consumer-rules.pro")
45+
multiDexEnabled = true
46+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
47+
}
48+
buildTypes {
49+
release {
50+
isMinifyEnabled = false
51+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
52+
}
53+
}
54+
compileOptions {
55+
sourceCompatibility = JavaVersion.VERSION_1_8
56+
targetCompatibility = JavaVersion.VERSION_1_8
57+
}
58+
kotlinOptions { jvmTarget = "1.8" }
59+
testOptions {
60+
targetSdk = targetSdkVersion
61+
unitTests {
62+
isIncludeAndroidResources = true
63+
isReturnDefaultValues = true
64+
}
65+
}
66+
lint {
67+
targetSdk = targetSdkVersion
68+
baseline = file("lint-baseline.xml")
69+
}
70+
sourceSets { getByName("test").java.srcDirs("src/testUtil") }
71+
}
72+
73+
// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any
74+
// classes, methods, or properties have implicit `public` visibility. This check helps
75+
// avoid accidentally leaking elements into the public API, requiring that any public
76+
// element be explicitly declared as `public`.
77+
// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md
78+
// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1
79+
tasks.withType<KotlinCompile>().all {
80+
if (!name.contains("test", ignoreCase = true)) {
81+
if (!kotlinOptions.freeCompilerArgs.contains("-Xexplicit-api=strict")) {
82+
kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict"
83+
}
84+
}
85+
}
86+
87+
dependencies {
88+
implementation(libs.ktor.client.okhttp)
89+
implementation(libs.ktor.client.core)
90+
implementation(libs.ktor.client.websockets)
91+
implementation(libs.ktor.client.content.negotiation)
92+
implementation(libs.ktor.serialization.kotlinx.json)
93+
implementation(libs.ktor.client.logging)
94+
95+
api("com.google.firebase:firebase-common:21.0.0")
96+
implementation("com.google.firebase:firebase-components:18.0.0")
97+
implementation("com.google.firebase:firebase-annotations:16.2.0")
98+
implementation("com.google.firebase:firebase-appcheck-interop:17.1.0")
99+
implementation(libs.androidx.annotation)
100+
implementation(libs.kotlinx.serialization.json)
101+
implementation(libs.androidx.core.ktx)
102+
implementation(libs.slf4j.nop)
103+
implementation(libs.kotlinx.coroutines.android)
104+
implementation(libs.kotlinx.coroutines.reactive)
105+
implementation(libs.reactive.streams)
106+
implementation("com.google.guava:listenablefuture:1.0")
107+
implementation("androidx.concurrent:concurrent-futures:1.2.0")
108+
implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0")
109+
implementation("com.google.firebase:firebase-auth-interop:18.0.0")
110+
111+
testImplementation(libs.kotest.assertions.core)
112+
testImplementation(libs.kotest.assertions)
113+
testImplementation(libs.kotest.assertions.json)
114+
testImplementation(libs.ktor.client.okhttp)
115+
testImplementation(libs.ktor.client.mock)
116+
testImplementation(libs.org.json)
117+
testImplementation(libs.androidx.test.junit)
118+
testImplementation(libs.androidx.test.runner)
119+
testImplementation(libs.junit)
120+
testImplementation(libs.kotlin.coroutines.test)
121+
testImplementation(libs.robolectric)
122+
testImplementation(libs.truth)
123+
testImplementation(libs.mockito.core)
124+
125+
androidTestImplementation(libs.androidx.espresso.core)
126+
androidTestImplementation(libs.androidx.test.junit)
127+
androidTestImplementation(libs.androidx.test.runner)
128+
androidTestImplementation(libs.truth)
129+
}

firebase-ai/gradle.properties

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
version=16.0.0
16+
latestReleasedVersion=

firebase-ai/lint-baseline.xml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2025 Google LLC
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<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">
18+
19+
20+
</issues>

firebase-ai/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright 2024 Google LLC -->
3+
<!-- -->
4+
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
5+
<!-- you may not use this file except in compliance with the License. -->
6+
<!-- You may obtain a copy of the License at -->
7+
<!-- -->
8+
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
9+
<!-- -->
10+
<!-- Unless required by applicable law or agreed to in writing, software -->
11+
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
12+
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
13+
<!-- See the License for the specific language governing permissions and -->
14+
<!-- limitations under the License. -->
15+
16+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
17+
<!--Although the *SdkVersion is captured in gradle build files, this is required for non gradle builds-->
18+
<!--<uses-sdk android:minSdkVersion="21"/>-->
19+
20+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
21+
<uses-permission android:name="android.permission.INTERNET" />
22+
23+
<!-- To use the audio conversation feature of Live Sessions, update your app's manifest -->
24+
<!-- to request audio recording permission -->
25+
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
26+
27+
<application>
28+
<service android:name="com.google.firebase.components.ComponentDiscoveryService"
29+
android:exported="false">
30+
<meta-data
31+
android:name="com.google.firebase.components:com.google.firebase.ai.FirebaseAIRegistrar"
32+
android:value="com.google.firebase.components.ComponentRegistrar" />
33+
</service>
34+
</application>
35+
</manifest>

0 commit comments

Comments
 (0)