From 6c580c86cf756eb3db2f619a60d681734a0637f7 Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Mon, 4 Nov 2024 18:40:07 -0500 Subject: [PATCH] [Vertex AI] Fix parallel function calling in sample --- .../ViewModels/FunctionCallingViewModel.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FirebaseVertexAI/Sample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift b/FirebaseVertexAI/Sample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift index 7a67175112f..80f75acea6f 100644 --- a/FirebaseVertexAI/Sample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift +++ b/FirebaseVertexAI/Sample/FunctionCallingSample/ViewModels/FunctionCallingViewModel.swift @@ -116,7 +116,7 @@ class FunctionCallingViewModel: ObservableObject { for functionResponse in functionResponses { messages.insert(functionResponse.chatMessage(), at: messages.count - 1) } - responseStream = try chat.sendMessageStream(functionResponses.modelContent()) + responseStream = try chat.sendMessageStream([functionResponses.modelContent()]) } for try await chunk in responseStream { processResponseContent(content: chunk) @@ -132,7 +132,7 @@ class FunctionCallingViewModel: ObservableObject { for functionResponse in functionResponses { messages.insert(functionResponse.chatMessage(), at: messages.count - 1) } - response = try await chat.sendMessage(functionResponses.modelContent()) + response = try await chat.sendMessage([functionResponses.modelContent()]) } processResponseContent(content: response) } @@ -249,7 +249,7 @@ private extension FunctionResponsePart { } private extension [FunctionResponsePart] { - func modelContent() -> [ModelContent] { - return self.map { ModelContent(role: "function", parts: [$0]) } + func modelContent() -> ModelContent { + return ModelContent(role: "function", parts: self) } }