Skip to content

Commit 84e0def

Browse files
rlazothatfiredev
andauthored
Bump vertex version to beta01 (#1613)
* Bump vertex version to beta01 * get first function call --------- Co-authored-by: Rosário P. Fernandes <[email protected]>
1 parent 2edbc52 commit 84e0def

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

vertexai/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dependencies {
6767

6868
implementation("io.coil-kt:coil-compose:2.5.0")
6969
implementation("com.google.firebase:firebase-analytics:21.6.1")
70-
implementation("com.google.firebase:firebase-vertexai:16.0.0-alpha03")
70+
implementation("com.google.firebase:firebase-vertexai:16.0.0-beta01")
7171

7272
testImplementation("junit:junit:4.13.2")
7373
androidTestImplementation("androidx.test.ext:junit:1.1.5")

vertexai/app/src/main/kotlin/com/google/firebase/quickstart/vertexai/feature/functioncalling/FunctionsChatViewModel.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@ class FunctionsChatViewModel(
7373
var response =
7474
chat.sendMessage("What would be the uppercase representation of the following text: $userMessage")
7575

76-
if (response.functionCall != null) {
76+
// Getting the first matched function call
77+
val firstFunctionCall = response.functionCalls.firstOrNull()
78+
79+
if (firstFunctionCall != null) {
7780
val matchingFunction =
7881
generativeModel.tools?.flatMap { it.functionDeclarations }
79-
?.first { it.name == response.functionCall?.name }
82+
?.first { it.name == firstFunctionCall.name }
8083
?: throw InvalidStateException(
81-
"Model requested nonexistent function \"${response.functionCall?.name}\" "
84+
"Model requested nonexistent function \"${firstFunctionCall.name}\" "
8285
)
8386

84-
val funResult = matchingFunction.execute(response.functionCall!!)
87+
val funResult = matchingFunction.execute(firstFunctionCall)
8588

8689
response = chat.sendMessage(
8790
content(role = "function") {

0 commit comments

Comments
 (0)