Skip to content

Commit c0ae8c0

Browse files
committed
Restructured data parsing to reduce logging
Logs are poluted by trying to parse function calling first, and then a regular response.
1 parent d730323 commit c0ae8c0

File tree

1 file changed

+16
-16
lines changed
  • firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type

1 file changed

+16
-16
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,6 @@ internal constructor(
269269
continue
270270
}
271271
try {
272-
val functionContent = Json.decodeFromString<ToolCallSetup.Internal>(receivedJson)
273-
emit(
274-
LiveContentResponse(
275-
null,
276-
LiveContentResponse.Status.NORMAL,
277-
functionContent.toolCall.functionCalls.map {
278-
FunctionCallPart(it.name, it.args.orEmpty().mapValues { x -> x.value ?: JsonNull })
279-
}
280-
)
281-
)
282-
continue
283-
} catch (e: Exception) {
284-
Log.i(TAG, "Failed to decode function calling: ${e.message}")
285-
}
286-
try {
287-
288272
val serverContent = Json.decodeFromString<ServerContentSetup.Internal>(receivedJson)
289273
val data = serverContent.serverContent.modelTurn.toPublic()
290274
if (outputModalities.contains(ContentModality.AUDIO)) {
@@ -297,9 +281,25 @@ internal constructor(
297281
emit(LiveContentResponse(data, LiveContentResponse.Status.NORMAL, null))
298282
}
299283
}
284+
continue
300285
} catch (e: Exception) {
301286
Log.i(TAG, "Failed to decode server content: ${e.message}")
302287
}
288+
try {
289+
val functionContent = Json.decodeFromString<ToolCallSetup.Internal>(receivedJson)
290+
emit(
291+
LiveContentResponse(
292+
null,
293+
LiveContentResponse.Status.NORMAL,
294+
functionContent.toolCall.functionCalls.map {
295+
FunctionCallPart(it.name, it.args.orEmpty().mapValues { x -> x.value ?: JsonNull })
296+
}
297+
)
298+
)
299+
continue
300+
} catch (e: Exception) {
301+
Log.i(TAG, "Failed to decode function calling: ${e.message}")
302+
}
303303
}
304304
}
305305
}

0 commit comments

Comments
 (0)