Skip to content

Commit 6e68228

Browse files
committed
Update TODOs
1 parent f89b462 commit 6e68228

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

FirebaseVertexAI/Sources/Types/Public/Imagen/ImagenGenerationResponse.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ extension ImagenGenerationResponse: Decodable where T: Decodable {
5050

5151
public init(from decoder: any Decoder) throws {
5252
let container = try decoder.container(keyedBy: CodingKeys.self)
53-
guard container.contains(.predictions) else {
54-
images = []
55-
filteredReason = nil
56-
// TODO(#14221): Log warning if no predictions.
57-
return
58-
}
5953
var predictionsContainer = try container.nestedUnkeyedContainer(forKey: .predictions)
6054

6155
var images = [T]()
@@ -66,7 +60,7 @@ extension ImagenGenerationResponse: Decodable where T: Decodable {
6660
} else if let filteredReason = try? predictionsContainer.decode(RAIFilteredReason.self) {
6761
filteredReasons.append(filteredReason.raiFilteredReason)
6862
} else if let _ = try? predictionsContainer.decode(JSONObject.self) {
69-
// TODO(#14221): Log or throw unsupported prediction type
63+
// TODO(#14221): Log unsupported prediction type message with the decoded `JSONObject`.
7064
} else {
7165
// This should never be thrown since JSONObject accepts any valid JSON.
7266
throw DecodingError.dataCorruptedError(
@@ -77,7 +71,7 @@ extension ImagenGenerationResponse: Decodable where T: Decodable {
7771
}
7872

7973
self.images = images
80-
filteredReason = filteredReasons.first
81-
// TODO(#14221): Log if more than one RAI Filtered Reason; unexpected behaviour.
74+
filteredReason = filteredReasons.joined(separator: "\n")
75+
// TODO(#14221): Throw `ImagenImagesBlockedError` with `filteredReason` if `images` is empty.
8276
}
8377
}

0 commit comments

Comments
 (0)