/
ChatGptResponse.cs
62 lines (53 loc) · 2.52 KB
/
ChatGptResponse.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using ChatGptNet.Models.Common;
using ChatGptNet.Models.Converters;
namespace ChatGptNet.Models;
/// <summary>
/// Represents a chat completion response.
/// </summary>
public class ChatGptResponse : Response
{
/// <summary>
/// Gets or sets the Id of the response.
/// </summary>
public string Id { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the Conversation Id, that is used to group messages of the same conversation.
/// </summary>
public Guid ConversationId { get; set; }
/// <summary>
/// Gets or sets the UTC date and time at which the response has been generated.
/// </summary>
[JsonPropertyName("created")]
[JsonConverter(typeof(UnixToDateTimeConverter))]
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
/// <summary>
/// Gets or sets the list of choices that has been provided by chat completion.
/// </summary>
public IEnumerable<ChatGptChoice> Choices { get; set; } = Enumerable.Empty<ChatGptChoice>();
/// <summary>
/// This fingerprint represents the backend configuration that the model runs with.
/// Can be used in conjunction with the <see cref="ChatGptParameters.Seed"/> request parameter to understand when backend changes have been made that might impact determinism.
/// </summary>
[JsonPropertyName("system_fingerprint")]
public string? SystemFingerprint { get; set; }
/// <summary>
/// Gets or sets the list of prompt filter results determined by the content filtering system.
/// </summary>
[JsonPropertyName("prompt_filter_results")]
public IEnumerable<ChatGptPromptFilterResults>? PromptFilterResults { get; set; }
/// <summary>
/// Gets or sets a value indicating whether any prompt has been filtered by the content filtering system.
/// </summary>
[MemberNotNullWhen(true, nameof(PromptFilterResults))]
public bool IsPromptFiltered => PromptFilterResults?.Any(
p => p.ContentFilterResults.Hate.Filtered || p.ContentFilterResults.SelfHarm.Filtered || p.ContentFilterResults.Violence.Filtered
|| p.ContentFilterResults.Sexual.Filtered) ?? false;
/// <summary>
/// Gets a value indicating whether the first choice, if available, has been filtered by the content filtering system.
/// </summary>
/// <seealso cref="ChatGptChoice"/>
/// <seealso cref="ChatGptChoice.IsFiltered"/>
public bool IsContentFiltered => Choices.FirstOrDefault()?.IsFiltered ?? false;
}