From 67bc6b41e1a6e4e3984614acd975ab80f144fb79 Mon Sep 17 00:00:00 2001 From: Marco Minerva Date: Thu, 3 Aug 2023 15:00:55 +0200 Subject: [PATCH] Add nullability annotations #98 --- src/ChatGptNet/Models/ChatGptChoice.cs | 4 +++- src/ChatGptNet/Models/ChatGptResponse.cs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ChatGptNet/Models/ChatGptChoice.cs b/src/ChatGptNet/Models/ChatGptChoice.cs index 39e509d..c8e8076 100644 --- a/src/ChatGptNet/Models/ChatGptChoice.cs +++ b/src/ChatGptNet/Models/ChatGptChoice.cs @@ -1,4 +1,5 @@ -using System.Text.Json.Serialization; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; namespace ChatGptNet.Models; @@ -29,6 +30,7 @@ public class ChatGptChoice /// Gets or sets a value indicating whether the this has been filtered by content filtering system. /// /// + [MemberNotNullWhen(true, nameof(ContentFilterResults))] public bool IsChoiceFiltered => ContentFilterResults is not null && (ContentFilterResults.Hate.Filtered || ContentFilterResults.SelfHarm.Filtered || ContentFilterResults.Violence.Filtered || ContentFilterResults.Sexual.Filtered); diff --git a/src/ChatGptNet/Models/ChatGptResponse.cs b/src/ChatGptNet/Models/ChatGptResponse.cs index 09e285d..fa639e7 100644 --- a/src/ChatGptNet/Models/ChatGptResponse.cs +++ b/src/ChatGptNet/Models/ChatGptResponse.cs @@ -1,4 +1,5 @@ -using System.Text.Json.Serialization; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; using ChatGptNet.Models.Converters; namespace ChatGptNet.Models; @@ -59,6 +60,7 @@ public class ChatGptResponse /// /// Gets or sets a value indicating whether any prompt has been filtered by content filtering system. /// + [MemberNotNullWhen(true, nameof(PromptAnnotations))] public bool IsPromptFiltered => PromptAnnotations?.Any( p => p.ContentFilterResults.Hate.Filtered || p.ContentFilterResults.SelfHarm.Filtered || p.ContentFilterResults.Violence.Filtered || p.ContentFilterResults.Sexual.Filtered) ?? false; @@ -66,6 +68,7 @@ public class ChatGptResponse /// /// Gets a value that determines if the response was successful. /// + [MemberNotNullWhen(false, nameof(Error))] public bool IsSuccessful => Error is null; ///