@@ -214,7 +214,8 @@ internal constructor(
214
214
FirebaseVertexAIException .catchAsync {
215
215
val jsonString =
216
216
Json .encodeToString(
217
- LiveToolResponseSetup (functionList.map { it.toInternalFunctionCall() }).toInternal()
217
+ BidiGenerateContentToolResponseSetup (functionList.map { it.toInternalFunctionCall() })
218
+ .toInternal()
218
219
)
219
220
session.send(Frame .Text (jsonString))
220
221
}
@@ -233,7 +234,7 @@ internal constructor(
233
234
FirebaseVertexAIException .catchAsync {
234
235
val jsonString =
235
236
Json .encodeToString(
236
- LiveClientRealtimeInputSetup (mediaChunks.map { (it.toInternal()) }).toInternal()
237
+ BidiGenerateContentRealtimeInputSetup (mediaChunks.map { (it.toInternal()) }).toInternal()
237
238
)
238
239
session.send(Frame .Text (jsonString))
239
240
}
@@ -249,7 +250,9 @@ internal constructor(
249
250
public suspend fun send (content : Content ) {
250
251
FirebaseVertexAIException .catchAsync {
251
252
val jsonString =
252
- Json .encodeToString(LiveClientContentSetup (listOf (content.toInternal()), true ).toInternal())
253
+ Json .encodeToString(
254
+ BidiGenerateContentClientContentSetup (listOf (content.toInternal()), true ).toInternal()
255
+ )
253
256
session.send(Frame .Text (jsonString))
254
257
}
255
258
}
@@ -380,7 +383,8 @@ internal constructor(
380
383
381
384
return when {
382
385
" toolCall" in jsonMessage -> {
383
- val functionContent = JSON .decodeFromJsonElement<LiveServerToolCall .Internal >(jsonMessage)
386
+ val functionContent =
387
+ JSON .decodeFromJsonElement<BidiGenerateContentToolCallSetup .Internal >(jsonMessage)
384
388
LiveContentResponse (
385
389
null ,
386
390
LiveContentResponse .Status .NORMAL ,
@@ -391,7 +395,8 @@ internal constructor(
391
395
}
392
396
" serverContent" in jsonMessage -> {
393
397
val serverContent =
394
- JSON .decodeFromJsonElement<LiveServerContentSetup .Internal >(jsonMessage).serverContent
398
+ JSON .decodeFromJsonElement<BidiGenerateContentServerContentSetup .Internal >(jsonMessage)
399
+ .serverContent
395
400
val status =
396
401
when {
397
402
serverContent.turnComplete == true -> LiveContentResponse .Status .TURN_COMPLETE
@@ -412,92 +417,95 @@ internal constructor(
412
417
*
413
418
* Effectively, a message from the client to the model.
414
419
*/
415
- internal class LiveClientContentSetup (
420
+ internal class BidiGenerateContentClientContentSetup (
416
421
val turns : List <Content .Internal >,
417
422
val turnComplete : Boolean
418
423
) {
419
424
@Serializable
420
- internal class Internal (val clientContent : LiveClientContent ) {
425
+ internal class Internal (val clientContent : BidiGenerateContentClientContent ) {
421
426
@Serializable
422
- internal data class LiveClientContent (
427
+ internal data class BidiGenerateContentClientContent (
423
428
val turns : List <Content .Internal >,
424
429
val turnComplete : Boolean
425
430
)
426
431
}
427
432
428
- fun toInternal () = Internal (Internal .LiveClientContent (turns, turnComplete))
433
+ fun toInternal () = Internal (Internal .BidiGenerateContentClientContent (turns, turnComplete))
429
434
}
430
435
431
436
/* *
432
437
* Incremental server update generated by the model in response to client messages.
433
438
*
434
439
* Effectively, a message from the model to the client.
435
440
*/
436
- internal class LiveServerContentSetup (
441
+ internal class BidiGenerateContentServerContentSetup (
437
442
val modelTurn : Content .Internal ? ,
438
443
val turnComplete : Boolean? ,
439
444
val interrupted : Boolean?
440
445
) {
441
446
@Serializable
442
- internal class Internal (val serverContent : LiveServerContent ) {
447
+ internal class Internal (val serverContent : BidiGenerateContentServerContent ) {
443
448
@Serializable
444
- internal data class LiveServerContent (
449
+ internal data class BidiGenerateContentServerContent (
445
450
val modelTurn : Content .Internal ? ,
446
451
val turnComplete : Boolean? ,
447
452
val interrupted : Boolean?
448
453
)
449
454
}
450
455
451
- fun toInternal () = Internal (Internal .LiveServerContent (modelTurn, turnComplete, interrupted))
456
+ fun toInternal () =
457
+ Internal (Internal .BidiGenerateContentServerContent (modelTurn, turnComplete, interrupted))
452
458
}
453
459
454
460
/* *
455
461
* Request for the client to execute the provided function calls and return the responses with the
456
462
* matched `id`s.
457
463
*/
458
- internal data class LiveServerToolCall (
464
+ internal data class BidiGenerateContentToolCallSetup (
459
465
val functionCalls : List <FunctionCallPart .Internal .FunctionCall >
460
466
) {
461
467
@Serializable
462
- internal class Internal (val toolCall : LiveServerToolCall ) {
468
+ internal class Internal (val toolCall : BidiGenerateContentToolCall ) {
463
469
@Serializable
464
- internal data class LiveServerToolCall (
470
+ internal data class BidiGenerateContentToolCall (
465
471
val functionCalls : List <FunctionCallPart .Internal .FunctionCall >
466
472
)
467
473
}
468
474
469
475
fun toInternal (): Internal {
470
- return Internal (Internal .LiveServerToolCall (functionCalls))
476
+ return Internal (Internal .BidiGenerateContentToolCall (functionCalls))
471
477
}
472
478
}
473
479
474
- /* * Client generated responses to a [LiveServerToolCall ]. */
475
- internal class LiveToolResponseSetup (
480
+ /* * Client generated responses to a [BidiGenerateContentToolCallSetup ]. */
481
+ internal class BidiGenerateContentToolResponseSetup (
476
482
val functionResponses : List <FunctionResponsePart .Internal .FunctionResponse >
477
483
) {
478
484
@Serializable
479
- internal data class Internal (val toolResponse : LiveToolResponse ) {
485
+ internal data class Internal (val toolResponse : BidiGenerateContentToolResponse ) {
480
486
@Serializable
481
- internal data class LiveToolResponse (
487
+ internal data class BidiGenerateContentToolResponse (
482
488
val functionResponses : List <FunctionResponsePart .Internal .FunctionResponse >
483
489
)
484
490
}
485
491
486
- fun toInternal () = Internal (Internal .LiveToolResponse (functionResponses))
492
+ fun toInternal () = Internal (Internal .BidiGenerateContentToolResponse (functionResponses))
487
493
}
488
494
489
495
/* *
490
496
* User input that is sent to the model in real time.
491
497
*
492
498
* End of turn is derived from user activity (eg; end of speech).
493
499
*/
494
- internal class LiveClientRealtimeInputSetup (val mediaChunks : List <MediaData .Internal >) {
500
+ internal class BidiGenerateContentRealtimeInputSetup (val mediaChunks : List <MediaData .Internal >) {
495
501
@Serializable
496
- internal class Internal (val realtimeInput : LiveClientRealtimeInput ) {
502
+ internal class Internal (val realtimeInput : BidiGenerateContentRealtimeInput ) {
497
503
@Serializable
498
- internal data class LiveClientRealtimeInput (val mediaChunks : List <MediaData .Internal >)
504
+ internal data class BidiGenerateContentRealtimeInput (
505
+ val mediaChunks : List <MediaData .Internal >
506
+ )
499
507
}
500
- fun toInternal () = Internal (Internal .LiveClientRealtimeInput (mediaChunks))
508
+ fun toInternal () = Internal (Internal .BidiGenerateContentRealtimeInput (mediaChunks))
501
509
}
502
510
503
511
private companion object {
0 commit comments