Skip to content

Commit

Permalink
[Vertex AI] Fix parallel function calling in sample
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed Nov 4, 2024
1 parent 0a49232 commit 6c580c8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 6c580c8

Please sign in to comment.