Skip to content

Commit

Permalink
Fix sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard committed Oct 3, 2024
1 parent 8a99f99 commit afda484
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ class FunctionCallingViewModel: ObservableObject {

for part in candidate.content.parts {
switch part {
case let .text(text):
case let textPart as TextPart:
// replace pending message with backend response
messages[messages.count - 1].message += text
messages[messages.count - 1].message += textPart.textValue
messages[messages.count - 1].pending = false
case let .functionCall(functionCall):
case let functionCallPart as FunctionCallPart:
let functionCall = functionCallPart.functionCall
messages.insert(functionCall.chatMessage(), at: messages.count - 1)
functionCalls.append(functionCall)
case .inlineData, .fileData, .functionResponse, .error:
default:
fatalError("Unsupported response content.")
}
}
Expand Down Expand Up @@ -252,7 +253,7 @@ private extension [FunctionResponse] {
func modelContent() -> [ModelContent] {
return self.map { ModelContent(
role: "function",
parts: [ModelContent.Part.functionResponse($0)]
parts: [FunctionResponsePart(functionResponse: $0)]
)
}
}
Expand Down

0 comments on commit afda484

Please sign in to comment.