Skip to content

Commit de501f0

Browse files
authored
add GenerativeContentResponse#functionCalls (#5931)
1 parent 6b683f7 commit de501f0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ class GenerateContentResponse(
3333
/** Convenience field representing the first text part in the response, if it exists. */
3434
val text: String? by lazy { firstPartAs<TextPart>()?.text }
3535

36-
/** Convenience field representing the first text part in the response, if it exists. */
37-
val functionCall: FunctionCallPart? by lazy { firstPartAs() }
36+
/** Convenience field to get all the function call parts in the request, if they exist */
37+
val functionCalls: List<FunctionCallPart> by lazy {
38+
candidates.first().content.parts.filterIsInstance<FunctionCallPart>()
39+
}
3840

39-
/** Convenience field representing the first text part in the response, if it exists. */
41+
/**
42+
* Convenience field representing the first function response part in the response, if it exists.
43+
*/
4044
val functionResponse: FunctionResponsePart? by lazy { firstPartAs() }
4145

4246
private inline fun <reified T : Part> firstPartAs(): T? {

0 commit comments

Comments
 (0)