Skip to content

Commit 1b5d791

Browse files
andrewhearddaymxn
authored andcommitted
Fix BidiGenerateContentClientMessage encoding
1 parent af76cbc commit 1b5d791

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

FirebaseAI/Sources/Types/Internal/Live/BidiGenerateContentClientMessage.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Foundation
1616

1717
/// Messages sent by the client in the BidiGenerateContent RPC call.
18-
enum BidiGenerateContentClientMessage: Encodable {
18+
enum BidiGenerateContentClientMessage {
1919
/// Message to be sent in the first and only first client message.
2020
case setup(BidiGenerateContentSetup)
2121

@@ -28,3 +28,26 @@ enum BidiGenerateContentClientMessage: Encodable {
2828
/// Response to a `ToolCallMessage` received from the server.
2929
case toolResponse(BidiGenerateContentToolResponse)
3030
}
31+
32+
extension BidiGenerateContentClientMessage: Encodable {
33+
enum CodingKeys: CodingKey {
34+
case setup
35+
case clientContent
36+
case realtimeInput
37+
case toolResponse
38+
}
39+
40+
func encode(to encoder: any Encoder) throws {
41+
var container = encoder.container(keyedBy: CodingKeys.self)
42+
switch self {
43+
case let .setup(setup):
44+
try container.encode(setup, forKey: .setup)
45+
case let .clientContent(clientContent):
46+
try container.encode(clientContent, forKey: .clientContent)
47+
case let .realtimeInput(realtimeInput):
48+
try container.encode(realtimeInput, forKey: .realtimeInput)
49+
case let .toolResponse(toolResponse):
50+
try container.encode(toolResponse, forKey: .toolResponse)
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)