Skip to content

Commit 35ad9aa

Browse files
authored
[Firebase AI] Handle a response with no Parts (#1319)
1 parent 1815c6e commit 35ad9aa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

firebaseai/src/ModelContent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ internal static ModelContent FromJson(Dictionary<string, object> jsonDict) {
402402
// If the role is missing, default to model since this is likely coming from the backend.
403403
jsonDict.ParseValue("role", defaultValue: "model"),
404404
// Unknown parts are converted to null, which we then want to filter out here
405-
jsonDict.ParseObjectList("parts", PartFromJson, JsonParseOptions.ThrowEverything).Where(p => p is not null));
405+
jsonDict.ParseObjectList("parts", PartFromJson)?.Where(p => p is not null));
406406
}
407407

408408
private static InlineDataPart InlineDataPartFromJson(Dictionary<string, object> jsonDict,

firebaseai/testapp/Assets/Firebase/Sample/FirebaseAI/UIHandlerAutomated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ async Task TestGenerateImage(Backend backend) {
713713
);
714714

715715
GenerateContentResponse response = await model.GenerateContentAsync(
716-
ModelContent.Text("Can you give me a picture of a cartoon dog, and a couple of sentences about him?")
716+
ModelContent.Text("Generate a picture of a cartoon dog, and a couple of sentences about him?")
717717
);
718718

719719
Assert("Response missing candidates.", response.Candidates.Any());

0 commit comments

Comments
 (0)