FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[AI] Introduce Agent Platform backend and deprecate Vertex AI (#8437) · firebase/firebase-android-sdk@092d67d · GitHub

Commit 092d67d

Browse files
andauthored
[AI] Introduce Agent Platform backend and deprecate Vertex AI (#8437)
Added support for the Agent Platform backend with a default location of "global". The existing `vertexAI` methods have been marked as deprecated in favor of `agentPlatform`. Updated internal request handling, URI construction, and service endpoints to integrate the new backend type. Internal b/535800463 --------- Co-authored-by: Mila <107142260+milaGGL@users.noreply.github.com>
1 parent f79bfbf commit 092d67d

8 files changed

Lines changed: 128 additions & 12 deletions

File tree

‎ai-logic/firebase-ai/CHANGELOG.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Unreleased
22

3+
- [changed] Deprecated `GenerativeBackend.vertexAI` in favor of
4+
`GenerativeBackend.agentPlatform` to reflect the renaming of Vertex
5+
AI to Gemini Enterprise Agent Platform. (#8437)
6+
7+
Note: The default location is now `global` instead of `us-central1` (no other
8+
functionality has changed). To continue using `us-central1`, specify
9+
`GenerativeBackend.agentPlatform(location = "us-central1"))`.
10+
311
# 17.14.0
412

513
- [feature] Added static factory methods `createWithThinking` for `Part` implementations to expose `thoughtSignature` and `isThought` properties. (#8352)
@@ -190,4 +198,3 @@ using [specific Gemini models](/docs/vertex-ai/models).
190198

191199
Note: This feature is in Public Preview, which means that it is not subject to any SLA or
192200
deprecation policy and could change in backwards-incompatible ways.
193-

‎ai-logic/firebase-ai/api.txt‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,16 +787,20 @@ package com.google.firebase.ai.type {
787787
}
788788

789789
public final class GenerativeBackend {
790+
method public static com.google.firebase.ai.type.GenerativeBackend agentPlatform();
791+
method public static com.google.firebase.ai.type.GenerativeBackend agentPlatform(String location = "global");
790792
method public static com.google.firebase.ai.type.GenerativeBackend googleAI();
791-
method public static com.google.firebase.ai.type.GenerativeBackend vertexAI();
792-
method public static com.google.firebase.ai.type.GenerativeBackend vertexAI(String location = "us-central1");
793+
method @Deprecated public static com.google.firebase.ai.type.GenerativeBackend vertexAI();
794+
method @Deprecated public static com.google.firebase.ai.type.GenerativeBackend vertexAI(String location = "us-central1");
793795
field public static final com.google.firebase.ai.type.GenerativeBackend.Companion Companion;
794796
}
795797

796798
public static final class GenerativeBackend.Companion {
799+
method public com.google.firebase.ai.type.GenerativeBackend agentPlatform();
800+
method public com.google.firebase.ai.type.GenerativeBackend agentPlatform(String location = "global");
797801
method public com.google.firebase.ai.type.GenerativeBackend googleAI();
798-
method public com.google.firebase.ai.type.GenerativeBackend vertexAI();
799-
method public com.google.firebase.ai.type.GenerativeBackend vertexAI(String location = "us-central1");
802+
method @Deprecated public com.google.firebase.ai.type.GenerativeBackend vertexAI();
803+
method @Deprecated public com.google.firebase.ai.type.GenerativeBackend vertexAI(String location = "us-central1");
800804
}
801805

802806
public final class GoogleMaps {

‎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.14.1
15+
version=17.15.0
1616
latestReleasedVersion=17.14.0

‎ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/FirebaseAI.kt‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ internal constructor(
117117
): GenerativeModel {
118118
val modelUri =
119119
when (backend.backend) {
120-
GenerativeBackendEnum.VERTEX_AI ->
120+
GenerativeBackendEnum.VERTEX_AI,
121+
GenerativeBackendEnum.AGENT_PLATFORM ->
121122
"projects/${firebaseApp.options.projectId}/locations/${backend.location}/publishers/google/models/${modelName}"
122123
GenerativeBackendEnum.GOOGLE_AI ->
123124
"projects/${firebaseApp.options.projectId}/models/${modelName}"
@@ -213,7 +214,8 @@ internal constructor(
213214
}
214215
return LiveGenerativeModel(
215216
when (backend.backend) {
216-
GenerativeBackendEnum.VERTEX_AI ->
217+
GenerativeBackendEnum.VERTEX_AI,
218+
GenerativeBackendEnum.AGENT_PLATFORM ->
217219
"projects/${firebaseApp.options.projectId}/locations/${backend.location}/publishers/google/models/${modelName}"
218220
GenerativeBackendEnum.GOOGLE_AI ->
219221
"projects/${firebaseApp.options.projectId}/models/${modelName}"
@@ -252,7 +254,8 @@ internal constructor(
252254
): ImagenModel {
253255
val modelUri =
254256
when (backend.backend) {
255-
GenerativeBackendEnum.VERTEX_AI ->
257+
GenerativeBackendEnum.VERTEX_AI,
258+
GenerativeBackendEnum.AGENT_PLATFORM ->
256259
"projects/${firebaseApp.options.projectId}/locations/${backend.location}/publishers/google/models/${modelName}"
257260
GenerativeBackendEnum.GOOGLE_AI ->
258261
"projects/${firebaseApp.options.projectId}/models/${modelName}"
@@ -358,7 +361,8 @@ internal constructor(
358361

359362
private fun getTemplateUri(backend: GenerativeBackend): String =
360363
when (backend.backend) {
361-
GenerativeBackendEnum.VERTEX_AI ->
364+
GenerativeBackendEnum.VERTEX_AI,
365+
GenerativeBackendEnum.AGENT_PLATFORM ->
362366
"projects/${firebaseApp.options.projectId}/locations/${backend.location}/templates/"
363367
GenerativeBackendEnum.GOOGLE_AI -> "projects/${firebaseApp.options.projectId}/templates/"
364368
}

‎ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/common/APIController.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ internal constructor(
249249
private fun getBidiEndpoint(location: String): String =
250250
when (backend?.backend) {
251251
GenerativeBackendEnum.VERTEX_AI,
252+
GenerativeBackendEnum.AGENT_PLATFORM,
252253
null ->
253254
"wss://firebasevertexai.googleapis.com/ws/google.firebase.vertexai.v1beta.LlmBidiService/BidiGenerateContent/locations/$location?key=$key"
254255
GenerativeBackendEnum.GOOGLE_AI ->

‎ai-logic/firebase-ai/src/main/kotlin/com/google/firebase/ai/generativemodel/CloudGenerativeModelProvider.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ internal class CloudGenerativeModelProvider(
121121
when (generativeBackend.backend) {
122122
GenerativeBackendEnum.GOOGLE_AI ->
123123
CountTokensRequest.forGoogleAI(buildGenerateContentRequest(prompt))
124-
GenerativeBackendEnum.VERTEX_AI ->
124+
GenerativeBackendEnum.VERTEX_AI,
125+
GenerativeBackendEnum.AGENT_PLATFORM ->
125126
CountTokensRequest.forVertexAI(buildGenerateContentRequest(prompt))
126127
}
127128

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ internal constructor(internal val location: String, internal val backend: Genera
3333
*
3434
* @param location passes a valid cloud server location, defaults to "us-central1"
3535
*/
36+
@Deprecated(
37+
message =
38+
"Use agentPlatform instead. Note that agentPlatform default location is \"global\" while" +
39+
" vertexAI was \"us-central1\".",
40+
replaceWith = ReplaceWith("agentPlatform(location)")
41+
)
3642
@JvmStatic
3743
@JvmOverloads
3844
public fun vertexAI(location: String = "us-central1"): GenerativeBackend {
@@ -41,6 +47,20 @@ internal constructor(internal val location: String, internal val backend: Genera
4147
}
4248
return GenerativeBackend(location, GenerativeBackendEnum.VERTEX_AI)
4349
}
50+
51+
/**
52+
* References the Gemini Enterprise Agent Platform backend.
53+
*
54+
* @param location passes a valid cloud server location, defaults to "global"
55+
*/
56+
@JvmStatic
57+
@JvmOverloads
58+
public fun agentPlatform(location: String = "global"): GenerativeBackend {
59+
if (location.isBlank() || location.contains("/")) {
60+
throw InvalidLocationException(location)
61+
}
62+
return GenerativeBackend(location, GenerativeBackendEnum.AGENT_PLATFORM)
63+
}
4464
}
4565

4666
override fun equals(other: Any?): Boolean {
@@ -49,7 +69,8 @@ internal constructor(internal val location: String, internal val backend: Genera
4969
GenerativeBackendEnum.GOOGLE_AI -> {
5070
other.backend == this.backend
5171
}
52-
GenerativeBackendEnum.VERTEX_AI -> {
72+
GenerativeBackendEnum.VERTEX_AI,
73+
GenerativeBackendEnum.AGENT_PLATFORM -> {
5374
other.backend == this.backend && other.location == this.location
5475
}
5576
}
@@ -63,4 +84,5 @@ internal constructor(internal val location: String, internal val backend: Genera
6384
internal enum class GenerativeBackendEnum {
6485
GOOGLE_AI,
6586
VERTEX_AI,
87+
AGENT_PLATFORM,
6688
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2026 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+
package com.google.firebase.ai.type
18+
19+
import io.kotest.assertions.throwables.shouldThrow
20+
import io.kotest.matchers.shouldBe
21+
import io.kotest.matchers.shouldNotBe
22+
import org.junit.Test
23+
24+
internal class GenerativeBackendTest {
25+
26+
@Test
27+
fun `agentPlatform default location`() {
28+
val backend = GenerativeBackend.agentPlatform()
29+
backend.location shouldBe "global"
30+
backend.backend shouldBe GenerativeBackendEnum.AGENT_PLATFORM
31+
}
32+
33+
@Test
34+
fun `agentPlatform custom location`() {
35+
val backend = GenerativeBackend.agentPlatform("europe-west1")
36+
backend.location shouldBe "europe-west1"
37+
backend.backend shouldBe GenerativeBackendEnum.AGENT_PLATFORM
38+
}
39+
40+
@Test
41+
fun `agentPlatform invalid locations throw exception`() {
42+
shouldThrow<InvalidLocationException> { GenerativeBackend.agentPlatform("") }
43+
shouldThrow<InvalidLocationException> { GenerativeBackend.agentPlatform(" ") }
44+
shouldThrow<InvalidLocationException> { GenerativeBackend.agentPlatform("us/central1") }
45+
}
46+
47+
@Test
48+
@Suppress("DEPRECATION")
49+
fun `vertexAI default location`() {
50+
val backend = GenerativeBackend.vertexAI()
51+
backend.location shouldBe "us-central1"
52+
backend.backend shouldBe GenerativeBackendEnum.VERTEX_AI
53+
}
54+
55+
@Test
56+
fun `googleAI properties`() {
57+
val backend = GenerativeBackend.googleAI()
58+
backend.location shouldBe ""
59+
backend.backend shouldBe GenerativeBackendEnum.GOOGLE_AI
60+
}
61+
62+
@Test
63+
@Suppress("DEPRECATION")
64+
fun `GenerativeBackend equality and hashcode`() {
65+
val agentPlatformGlobal1 = GenerativeBackend.agentPlatform("global")
66+
val agentPlatformGlobal2 = GenerativeBackend.agentPlatform("global")
67+
val agentPlatformUsCentral = GenerativeBackend.agentPlatform("us-central1")
68+
val vertexGlobal = GenerativeBackend.vertexAI("global")
69+
70+
agentPlatformGlobal1 shouldBe agentPlatformGlobal2
71+
agentPlatformGlobal1.hashCode() shouldBe agentPlatformGlobal2.hashCode()
72+
73+
agentPlatformGlobal1 shouldNotBe agentPlatformUsCentral
74+
agentPlatformGlobal1 shouldNotBe vertexGlobal
75+
agentPlatformGlobal1 shouldNotBe GenerativeBackend.googleAI()
76+
}
77+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL