Skip to content

Commit

Permalink
Add nullable annotations #98 (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva authored Aug 3, 2023
2 parents ec31833 + 67bc6b4 commit 8db82f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ChatGptNet/Models/ChatGptChoice.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace ChatGptNet.Models;

Expand Down Expand Up @@ -29,6 +30,7 @@ public class ChatGptChoice
/// Gets or sets a value indicating whether the this <see cref="ChatGptChoice"/> has been filtered by content filtering system.
/// </summary>
/// <seealso cref="ChatGptChoice"/>
[MemberNotNullWhen(true, nameof(ContentFilterResults))]
public bool IsChoiceFiltered => ContentFilterResults is not null
&& (ContentFilterResults.Hate.Filtered || ContentFilterResults.SelfHarm.Filtered || ContentFilterResults.Violence.Filtered
|| ContentFilterResults.Sexual.Filtered);
Expand Down
5 changes: 4 additions & 1 deletion src/ChatGptNet/Models/ChatGptResponse.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -59,13 +60,15 @@ public class ChatGptResponse
/// <summary>
/// Gets or sets a value indicating whether any prompt has been filtered by content filtering system.
/// </summary>
[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;

/// <summary>
/// Gets a value that determines if the response was successful.
/// </summary>
[MemberNotNullWhen(false, nameof(Error))]
public bool IsSuccessful => Error is null;

/// <summary>
Expand Down

0 comments on commit 8db82f4

Please sign in to comment.