Skip to content

Commit 876e98c

Browse files
committed
Merge branch 'main' into dl/url-context
2 parents 4a9a3ba + 9364dc3 commit 876e98c

File tree

17 files changed

+174
-53
lines changed

17 files changed

+174
-53
lines changed

.github/workflows/dataconnect.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ env:
3434
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
3535
FDC_ANDROID_EMULATOR_API_LEVEL: ${{ inputs.androidEmulatorApiLevel || '34' }}
3636
FDC_NODEJS_VERSION: ${{ inputs.nodeJsVersion || '20' }}
37-
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.15.1' }}
37+
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.16.0' }}
3838
FDC_FIREBASE_TOOLS_DIR: /tmp/firebase-tools
3939
FDC_FIREBASE_COMMAND: /tmp/firebase-tools/node_modules/.bin/firebase
4040
FDC_PYTHON_VERSION: ${{ inputs.pythonVersion || '3.13' }}

.github/workflows/dataconnect_demo_app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818

1919
env:
2020
FDC_NODE_VERSION: ${{ inputs.nodeVersion || '20' }}
21-
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.15.1' }}
21+
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.16.0' }}
2222
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
2323
FDC_FIREBASE_TOOLS_DIR: ${{ github.workspace }}/firebase-tools
2424
FDC_FIREBASE_COMMAND: ${{ github.workspace }}/firebase-tools/node_modules/.bin/firebase

firebase-ai/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
- [changed] **Breaking Change**: Removed the `candidateCount` option from `LiveGenerationConfig`
44
- [changed] Added support for the URL context tool, which allows the model to access content from
55
provided public web URLs to inform and enhance its responses.
6+
(#7382)
7+
- [changed] Added better error messages to `ServiceConnectionHandshakeFailedException` (#7412)
68

79
# 17.3.0
810

firebase-ai/src/androidTest/kotlin/com/google/firebase/ai/AIModels.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ class AIModels {
5151
flash2Model =
5252
FirebaseAI.getInstance(app!!, GenerativeBackend.vertexAI())
5353
.generativeModel(
54-
modelName = "gemini-2.0-flash",
54+
modelName = "gemini-2.5-flash",
5555
)
5656
flash2LiteModel =
5757
FirebaseAI.getInstance(app!!, GenerativeBackend.vertexAI())
5858
.generativeModel(
59-
modelName = "gemini-2.0-flash-lite",
59+
modelName = "gemini-2.5-flash-lite",
6060
)
6161
}
6262
}

firebase-ai/src/androidTest/kotlin/com/google/firebase/ai/ToolTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class ToolTests {
299299
val model =
300300
FirebaseAI.getInstance(app(), GenerativeBackend.vertexAI())
301301
.generativeModel(
302-
modelName = "gemini-2.0-flash",
302+
modelName = "gemini-2.5-flash",
303303
toolConfig =
304304
ToolConfig(
305305
functionCallingConfig = FunctionCallingConfig(FunctionCallingConfig.Mode.ANY)

firebase-ai/src/main/kotlin/com/google/firebase/ai/LiveGenerativeModel.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import com.google.firebase.ai.type.Tool
3232
import com.google.firebase.annotations.concurrent.Blocking
3333
import com.google.firebase.appcheck.interop.InteropAppCheckTokenProvider
3434
import com.google.firebase.auth.internal.InternalAuthProvider
35+
import io.ktor.client.plugins.websocket.DefaultClientWebSocketSession
3536
import io.ktor.websocket.Frame
3637
import io.ktor.websocket.close
3738
import io.ktor.websocket.readBytes
@@ -114,8 +115,9 @@ internal constructor(
114115
)
115116
.toInternal()
116117
val data: String = Json.encodeToString(clientMessage)
118+
var webSession: DefaultClientWebSocketSession? = null
117119
try {
118-
val webSession = controller.getWebSocketSession(location)
120+
webSession = controller.getWebSocketSession(location)
119121
webSession.send(Frame.Text(data))
120122
val receivedJsonStr = webSession.incoming.receive().readBytes().toString(Charsets.UTF_8)
121123
val receivedJson = JSON.parseToJsonElement(receivedJsonStr)
@@ -131,7 +133,10 @@ internal constructor(
131133
throw ServiceConnectionHandshakeFailedException("Unable to connect to the server")
132134
}
133135
} catch (e: ClosedReceiveChannelException) {
134-
throw ServiceConnectionHandshakeFailedException("Channel was closed by the server", e)
136+
val reason = webSession?.closeReason?.await()
137+
val message =
138+
"Channel was closed by the server.${if(reason!=null) " Details: ${reason.message}" else "" }"
139+
throw ServiceConnectionHandshakeFailedException(message, e)
135140
}
136141
}
137142

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import io.ktor.client.engine.HttpClientEngine
3838
import io.ktor.client.engine.okhttp.OkHttp
3939
import io.ktor.client.plugins.HttpTimeout
4040
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
41-
import io.ktor.client.plugins.websocket.ClientWebSocketSession
41+
import io.ktor.client.plugins.websocket.DefaultClientWebSocketSession
4242
import io.ktor.client.plugins.websocket.WebSockets
4343
import io.ktor.client.plugins.websocket.webSocketSession
4444
import io.ktor.client.request.HttpRequestBuilder
@@ -174,7 +174,7 @@ internal constructor(
174174
"wss://firebasevertexai.googleapis.com/ws/google.firebase.vertexai.v1beta.GenerativeService/BidiGenerateContent?key=$key"
175175
}
176176

177-
suspend fun getWebSocketSession(location: String): ClientWebSocketSession =
177+
suspend fun getWebSocketSession(location: String): DefaultClientWebSocketSession =
178178
client.webSocketSession(getBidiEndpoint(location)) { applyCommonHeaders() }
179179

180180
fun generateContentStream(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.google.firebase.ai.common.util.CancelledCoroutineScope
2929
import com.google.firebase.ai.common.util.accumulateUntil
3030
import com.google.firebase.ai.common.util.childJob
3131
import com.google.firebase.annotations.concurrent.Blocking
32-
import io.ktor.client.plugins.websocket.ClientWebSocketSession
32+
import io.ktor.client.plugins.websocket.DefaultClientWebSocketSession
3333
import io.ktor.websocket.Frame
3434
import io.ktor.websocket.close
3535
import io.ktor.websocket.readBytes
@@ -59,7 +59,7 @@ import kotlinx.serialization.json.Json
5959
@OptIn(ExperimentalSerializationApi::class)
6060
public class LiveSession
6161
internal constructor(
62-
private val session: ClientWebSocketSession,
62+
private val session: DefaultClientWebSocketSession,
6363
@Blocking private val blockingDispatcher: CoroutineContext,
6464
private var audioHelper: AudioHelper? = null,
6565
private val firebaseApp: FirebaseApp,

firebase-ai/src/test/java/com/google/firebase/ai/GenerativeModelTesting.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal class GenerativeModelTesting {
7272
val apiController =
7373
APIController(
7474
"super_cool_test_key",
75-
"gemini-1.5-flash",
75+
"gemini-2.5-flash",
7676
RequestOptions(timeout = 5.seconds, endpoint = "https://my.custom.endpoint"),
7777
mockEngine,
7878
TEST_CLIENT_ID,
@@ -84,7 +84,7 @@ internal class GenerativeModelTesting {
8484

8585
val generativeModel =
8686
GenerativeModel(
87-
"gemini-1.5-flash",
87+
"gemini-2.5-flash",
8888
systemInstruction = content { text("system instruction") },
8989
controller = apiController
9090
)
@@ -120,7 +120,7 @@ internal class GenerativeModelTesting {
120120
val apiController =
121121
APIController(
122122
"super_cool_test_key",
123-
"gemini-1.5-flash",
123+
"gemini-2.5-flash",
124124
RequestOptions(),
125125
mockEngine,
126126
TEST_CLIENT_ID,
@@ -133,7 +133,7 @@ internal class GenerativeModelTesting {
133133
// Creating the
134134
val generativeModel =
135135
GenerativeModel(
136-
"projects/PROJECTID/locations/INVALID_LOCATION/publishers/google/models/gemini-1.5-flash",
136+
"projects/PROJECTID/locations/INVALID_LOCATION/publishers/google/models/gemini-2.5-flash",
137137
controller = apiController
138138
)
139139

firebase-ai/src/test/java/com/google/firebase/ai/common/APIControllerTests.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ internal class RequestFormatTests {
114114
val controller =
115115
APIController(
116116
"super_cool_test_key",
117-
"gemini-pro-1.5",
117+
"gemini-pro-2.5",
118118
RequestOptions(),
119119
mockEngine,
120120
"genai-android/${BuildConfig.VERSION_NAME}",
@@ -144,7 +144,7 @@ internal class RequestFormatTests {
144144
val controller =
145145
APIController(
146146
"super_cool_test_key",
147-
"gemini-pro-1.5",
147+
"gemini-pro-2.5",
148148
RequestOptions(timeout = 5.seconds, endpoint = "https://my.custom.endpoint"),
149149
mockEngine,
150150
TEST_CLIENT_ID,
@@ -174,7 +174,7 @@ internal class RequestFormatTests {
174174
val controller =
175175
APIController(
176176
"super_cool_test_key",
177-
"gemini-pro-1.5",
177+
"gemini-pro-2.5",
178178
RequestOptions(),
179179
mockEngine,
180180
TEST_CLIENT_ID,
@@ -201,7 +201,7 @@ internal class RequestFormatTests {
201201
val controller =
202202
APIController(
203203
"super_cool_test_key",
204-
"gemini-pro-1.5",
204+
"gemini-pro-2.5",
205205
RequestOptions(),
206206
mockEngine,
207207
TEST_CLIENT_ID,
@@ -229,7 +229,7 @@ internal class RequestFormatTests {
229229
val controller =
230230
APIController(
231231
"super_cool_test_key",
232-
"gemini-pro-1.5",
232+
"gemini-pro-2.5",
233233
RequestOptions(),
234234
mockEngine,
235235
TEST_CLIENT_ID,
@@ -361,7 +361,7 @@ internal class RequestFormatTests {
361361
val controller =
362362
APIController(
363363
"super_cool_test_key",
364-
"gemini-pro-1.5",
364+
"gemini-pro-2.5",
365365
RequestOptions(),
366366
mockEngine,
367367
TEST_CLIENT_ID,
@@ -398,7 +398,7 @@ internal class RequestFormatTests {
398398
val controller =
399399
APIController(
400400
"super_cool_test_key",
401-
"gemini-pro-1.5",
401+
"gemini-pro-2.5",
402402
RequestOptions(),
403403
mockEngine,
404404
TEST_CLIENT_ID,
@@ -424,7 +424,7 @@ internal class RequestFormatTests {
424424
val controller =
425425
APIController(
426426
"super_cool_test_key",
427-
"gemini-pro-1.5",
427+
"gemini-pro-2.5",
428428
RequestOptions(),
429429
mockEngine,
430430
TEST_CLIENT_ID,

0 commit comments

Comments
 (0)