Skip to content

Commit a51d5c7

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/smoke-tests/src/androidTest/backend/functions/functions/protobufjs-7.6.0
2 parents 41d3dab + 85ee4b4 commit a51d5c7

49 files changed

Lines changed: 498 additions & 773 deletions

File tree

Some content is hidden

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

.github/workflows/app-distribution-gradle-compatibility-tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
permissions:
1414
contents: read
15+
issues: write
1516

1617
jobs:
1718
app-distribution-plugin:
@@ -52,3 +53,13 @@ jobs:
5253
with:
5354
name: integration-test-report
5455
path: firebase-appdistribution-gradle/build/reports/tests/
56+
57+
- name: Create GitHub Issue on Failure
58+
if: failure() && (github.event_name == 'schedule')
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
run: |
62+
gh issue create \
63+
--title "[firebase-appdistribution] Gradle Compatibility Tests Failed" \
64+
--body "The daily compatibility tests failed on the main branch. Please check the workflow logs here to diagnose the failure: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
65+
--label "bug,ci-failure,api: appdistribution"

.github/workflows/dataconnect.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ env:
3535
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
3636
FDC_ANDROID_EMULATOR_API_LEVEL: ${{ inputs.androidEmulatorApiLevel || '34' }}
3737
FDC_NODEJS_VERSION: ${{ inputs.nodeJsVersion || '20' }}
38-
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '15.18.0' }}
38+
FDC_INPUT_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion }}
3939
FDC_FIREBASE_TOOLS_DIR: /tmp/firebase-tools
4040
FDC_FIREBASE_COMMAND: /tmp/firebase-tools/node_modules/.bin/firebase
4141
FDC_PYTHON_VERSION: ${{ inputs.pythonVersion || '3.13' }}
@@ -54,6 +54,16 @@ jobs:
5454
with:
5555
show-progress: false
5656

57+
- name: Initialize FDC_FIREBASE_TOOLS_VERSION environment variable
58+
run: |
59+
set -euo pipefail
60+
if [[ -n "$FDC_INPUT_FIREBASE_TOOLS_VERSION" ]]; then
61+
version="$FDC_INPUT_FIREBASE_TOOLS_VERSION"
62+
else
63+
version="$(cat firebase-dataconnect/ci/firebase-tools-version.txt)"
64+
fi
65+
echo "FDC_FIREBASE_TOOLS_VERSION=${version}" >> "$GITHUB_ENV"
66+
5767
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
5868
with:
5969
java-version: ${{ env.FDC_JAVA_VERSION }}

.github/workflows/dataconnect_demo_app.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121

2222
env:
2323
FDC_NODE_VERSION: ${{ inputs.nodeVersion || '20' }}
24-
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '15.18.0' }}
24+
FDC_INPUT_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion }}
2525
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
2626
FDC_FIREBASE_TOOLS_DIR: ${{ github.workspace }}/firebase-tools
2727
FDC_FIREBASE_COMMAND: ${{ github.workspace }}/firebase-tools/node_modules/.bin/firebase
@@ -38,7 +38,19 @@ jobs:
3838
steps:
3939
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4040
with:
41-
sparse-checkout: firebase-dataconnect/demo
41+
sparse-checkout: |
42+
firebase-dataconnect/demo
43+
firebase-dataconnect/ci/
44+
45+
- name: Initialize FDC_FIREBASE_TOOLS_VERSION environment variable
46+
run: |
47+
set -euo pipefail
48+
if [[ -n "$FDC_INPUT_FIREBASE_TOOLS_VERSION" ]]; then
49+
version="$FDC_INPUT_FIREBASE_TOOLS_VERSION"
50+
else
51+
version="$(cat firebase-dataconnect/ci/firebase-tools-version.txt)"
52+
fi
53+
echo "FDC_FIREBASE_TOOLS_VERSION=${version}" >> "$GITHUB_ENV"
4254
4355
- name: Create Cache Key Files
4456
run: |

ai-logic/firebase-ai/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- [feature] Added the `retrievalConfig` argument to `TemplateToolConfig` (#8107)
34
- [fixed] Fixed citation indices to be native UTF-16 instead of UTF-8. (#8056)
45

56
# 17.12.0

ai-logic/firebase-ai/api.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ package com.google.firebase.ai {
213213
method @com.google.firebase.ai.type.PublicPreviewAPI public com.google.firebase.ai.TemplateChat startChat(String templateId, java.util.Map<java.lang.String,?> inputs, java.util.List<com.google.firebase.ai.type.Content> history = emptyList());
214214
}
215215

216-
@com.google.firebase.ai.type.PublicPreviewAPI public final class TemplateImagenModel {
217-
method public suspend Object? generateImages(String templateId, java.util.Map<java.lang.String,?> inputs, kotlin.coroutines.Continuation<? super com.google.firebase.ai.type.ImagenGenerationResponse<com.google.firebase.ai.type.ImagenInlineImage>>);
216+
@Deprecated @com.google.firebase.ai.type.PublicPreviewAPI public final class TemplateImagenModel {
217+
method @Deprecated public suspend Object? generateImages(String templateId, java.util.Map<java.lang.String,?> inputs, kotlin.coroutines.Continuation<? super com.google.firebase.ai.type.ImagenGenerationResponse<com.google.firebase.ai.type.ImagenInlineImage>>);
218218
}
219219

220220
}
@@ -1839,15 +1839,20 @@ package com.google.firebase.ai.type {
18391839

18401840
public final class TemplateTool {
18411841
method public static com.google.firebase.ai.type.TemplateTool functionDeclarations(java.util.List<? extends com.google.firebase.ai.type.TemplateFunctionDeclaration> functionDeclarations, java.util.List<? extends com.google.firebase.ai.type.TemplateAutoFunctionDeclaration<? extends java.lang.Object?,? extends java.lang.Object?>>? autoFunctionDeclarations = null);
1842+
method public static com.google.firebase.ai.type.TemplateTool googleMaps();
1843+
method public static com.google.firebase.ai.type.TemplateTool googleMaps(com.google.firebase.ai.type.GoogleMaps googleMaps = com.google.firebase.ai.type.GoogleMaps());
18421844
field public static final com.google.firebase.ai.type.TemplateTool.Companion Companion;
18431845
}
18441846

18451847
public static final class TemplateTool.Companion {
18461848
method public com.google.firebase.ai.type.TemplateTool functionDeclarations(java.util.List<? extends com.google.firebase.ai.type.TemplateFunctionDeclaration> functionDeclarations, java.util.List<? extends com.google.firebase.ai.type.TemplateAutoFunctionDeclaration<? extends java.lang.Object?,? extends java.lang.Object?>>? autoFunctionDeclarations = null);
1849+
method public com.google.firebase.ai.type.TemplateTool googleMaps();
1850+
method public com.google.firebase.ai.type.TemplateTool googleMaps(com.google.firebase.ai.type.GoogleMaps googleMaps = com.google.firebase.ai.type.GoogleMaps());
18471851
}
18481852

18491853
public final class TemplateToolConfig {
18501854
ctor public TemplateToolConfig();
1855+
ctor public TemplateToolConfig(com.google.firebase.ai.type.RetrievalConfig? retrievalConfig);
18511856
}
18521857

18531858
public final class TextPart implements com.google.firebase.ai.type.Part {

ai-logic/firebase-ai/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version=17.12.1
15+
version=17.13.0
1616
latestReleasedVersion=17.12.0

ai-logic/firebase-ai/src/androidTest/kotlin/com/google/firebase/ai/TemplateIntegrationTests.kt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@
1616

1717
package com.google.firebase.ai
1818

19+
import com.google.firebase.ai.type.GenerativeBackend
20+
import com.google.firebase.ai.type.LatLng
1921
import com.google.firebase.ai.type.PublicPreviewAPI
22+
import com.google.firebase.ai.type.RetrievalConfig
23+
import com.google.firebase.ai.type.TemplateTool
24+
import com.google.firebase.ai.type.TemplateToolConfig
2025
import io.kotest.matchers.collections.shouldNotBeEmpty
26+
import io.kotest.matchers.string.shouldContain
2127
import io.kotest.matchers.string.shouldContainIgnoringCase
28+
import io.kotest.matchers.string.shouldNotContain
2229
import kotlinx.coroutines.flow.toList
2330
import kotlinx.coroutines.runBlocking
2431
import org.junit.Before
@@ -102,4 +109,49 @@ class TemplateIntegrationTests {
102109
it shouldContainIgnoringCase topic
103110
}
104111
}
112+
113+
@Test
114+
fun testTemplateGroundingCity_googleAI(): Unit = runBlocking {
115+
val model =
116+
FirebaseAI.getInstance(AIModels.app(), GenerativeBackend.googleAI())
117+
.templateGenerativeModel(
118+
tools = listOf(TemplateTool.googleMaps()),
119+
toolConfig =
120+
TemplateToolConfig(
121+
RetrievalConfig(
122+
latLng = LatLng(latitude = 30.2672, longitude = -97.7431),
123+
languageCode = "en_US",
124+
)
125+
)
126+
)
127+
val responses =
128+
model
129+
.generateContentStream("maps-test-template-google-ai", mapOf("landmark" to "city"))
130+
.toList()
131+
responses
132+
.joinToString { it.text ?: "" }
133+
.lowercase()
134+
.replace(",", "")
135+
.replace(" ", " ") // Model sometimes doubles spacing
136+
.let { it shouldContainIgnoringCase "new york" }
137+
}
138+
139+
@Test
140+
fun testTemplateToolsUrlContext_googleAI(): Unit = runBlocking {
141+
val model =
142+
FirebaseAI.getInstance(AIModels.app(), GenerativeBackend.googleAI())
143+
.templateGenerativeModel(
144+
tools = listOf(), // URLContext not provided, still can read links
145+
)
146+
val response =
147+
model.generateContent(
148+
"url-context-test-template-google-ai",
149+
mapOf(
150+
"url" to "https://en.wikipedia.org/wiki/Kasane_Teto",
151+
"question" to "What is the given name of the linked individual?",
152+
)
153+
)
154+
response.text?.lowercase() shouldContain "teto"
155+
response.text?.lowercase() shouldNotContain "kasane"
156+
}
105157
}

ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/TemplateTool.kt

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616

1717
package com.google.firebase.ai.type
1818

19+
import kotlinx.serialization.InternalSerializationApi
1920
import kotlinx.serialization.Serializable
2021

2122
/**
2223
* Contains a set of tools (like function declarations) that the server template model has access
2324
* to.
2425
*/
2526
public class TemplateTool
26-
@OptIn(PublicPreviewAPI::class)
27+
@OptIn(PublicPreviewAPI::class, InternalSerializationApi::class)
2728
internal constructor(
2829
internal val functionDeclarations: List<TemplateFunctionDeclaration>?,
2930
internal val autoFunctionDeclarations: List<TemplateAutoFunctionDeclaration<*, *>>? = null,
31+
internal val googleMaps: GoogleMaps?,
3032
) {
3133

3234
@OptIn(PublicPreviewAPI::class)
@@ -36,11 +38,13 @@ internal constructor(
3638
functionDeclarations?.let { addAll(it.map { it.toInternal() }) }
3739
autoFunctionDeclarations?.let { addAll(it.map { it.toInternal() }) }
3840
},
41+
googleMaps?.toInternal(),
3942
)
4043

4144
@Serializable
4245
internal data class Internal(
4346
val templateFunctions: List<TemplateFunctionDeclaration.Internal>? = null,
47+
val googleMaps: GoogleMaps.Internal? = null,
4448
)
4549

4650
public companion object {
@@ -56,7 +60,27 @@ internal constructor(
5660
functionDeclarations: List<TemplateFunctionDeclaration>,
5761
autoFunctionDeclarations: List<TemplateAutoFunctionDeclaration<*, *>>? = null,
5862
): TemplateTool {
59-
return TemplateTool(functionDeclarations, autoFunctionDeclarations)
63+
return TemplateTool(functionDeclarations, autoFunctionDeclarations, null)
64+
}
65+
66+
/**
67+
* Creates a [TemplateTool] instance that allows the model to use grounding with Google Maps.
68+
*
69+
* Grounding with Google Maps can be used to allow the model to connect to Google Maps to
70+
* incorporate location-based information into its responses.
71+
*
72+
* When using this feature, you are required to comply with the "Grounding with Google Maps"
73+
* usage requirements for your chosen API provider:
74+
* [Gemini Developer API](https://ai.google.dev/gemini-api/terms#grounding-with-google-maps) or
75+
* Vertex AI Gemini API (see [Service Terms](https://cloud.google.com/terms/service-terms)
76+
* section within the Service Specific Terms).
77+
*
78+
* @return A [TemplateTool] configured for Google Maps.
79+
*/
80+
@JvmStatic
81+
@JvmOverloads
82+
public fun googleMaps(googleMaps: GoogleMaps = GoogleMaps()): TemplateTool {
83+
return TemplateTool(null, null, googleMaps)
6084
}
6185
}
6286
}
@@ -127,8 +151,13 @@ internal constructor(
127151
}
128152

129153
/** Config for template tools to use with server prompts. */
130-
public class TemplateToolConfig {
131-
internal fun toInternal(): ToolConfig.Internal? {
132-
return null // Empty config payload as defined in flutter API
154+
public class TemplateToolConfig public constructor(private val retrievalConfig: RetrievalConfig?) {
155+
156+
public constructor() : this(null)
157+
internal fun toInternal(): ToolConfig.Internal {
158+
return ToolConfig.Internal(
159+
functionCallingConfig = null,
160+
retrievalConfig = retrievalConfig?.toInternal()
161+
)
133162
}
134163
}

ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/type/Tool.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ internal constructor(
6161
public companion object {
6262

6363
@OptIn(PublicPreviewAPI::class)
64-
private val codeExecutionInstance by lazy {
64+
internal val codeExecutionInstance by lazy {
6565
Tool(null, null, null, JsonObject(emptyMap()), null, null)
6666
}
6767

@@ -118,7 +118,7 @@ internal constructor(
118118
* Creates a [Tool] instance that allows the model to use grounding with Google Search.
119119
*
120120
* Grounding with Google Search can be used to allow the model to connect to Google Search to
121-
* access and incorporate up-to-date information from the web into it's responses.
121+
* access and incorporate up-to-date information from the web into its responses.
122122
*
123123
* When using this feature, you are required to comply with the "grounding with Google Search"
124124
* usage requirements for your chosen API provider:

firebase-appdistribution-gradle/firebase-appdistribution-gradle.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ task integrationTest(type: Test) {
171171
description = 'Runs integration tests.'
172172
group = 'verification'
173173

174+
// Disable caching because the tests use com.google.firebase.appdistribution.gradle.VersionUtils,
175+
// which fetches the latest version from the internet.
176+
outputs.upToDateWhen { false }
177+
174178
testClassesDirs = sourceSets.integrationTest.output.classesDirs
175179
classpath = sourceSets.integrationTest.runtimeClasspath
176180

@@ -185,6 +189,10 @@ task prodTest(type: Test) {
185189
description = 'Runs prod tests.'
186190
group = 'verification'
187191

192+
// Disable caching because the tests use com.google.firebase.appdistribution.gradle.VersionUtils,
193+
// which fetches the latest version from the internet.
194+
outputs.upToDateWhen { false }
195+
188196
testClassesDirs = sourceSets.prodTest.output.classesDirs
189197
classpath = sourceSets.prodTest.runtimeClasspath
190198

0 commit comments

Comments
 (0)