/
ChatGptChoice.cs
67 lines (59 loc) · 2.77 KB
/
ChatGptChoice.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
63
64
65
66
67
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
namespace ChatGptNet.Models;
/// <summary>
/// Represent a chat completion choice.
/// </summary>
public class ChatGptChoice
{
/// <summary>
/// Gets or sets the index of the choice in the list.
/// </summary>
public int Index { get; set; }
/// <summary>
/// Gets or sets the message associated with this <see cref="ChatGptChoice"/>, if any.
/// </summary>
/// <seealso cref="ChatGptChoice"/>
public ChatGptMessage? Message { get; set; }
/// <summary>
/// Gets or sets the content filter results for the this <see cref="ChatGptChoice"/>.
/// </summary>
/// <seealso cref="ChatGptChoice"/>
[JsonPropertyName("content_filter_results")]
public ChatGptContentFilterResults? ContentFilterResults { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the this <see cref="ChatGptChoice"/> has been filtered by the content filtering system.
/// </summary>
/// <seealso cref="ChatGptChoice"/>
[MemberNotNullWhen(true, nameof(ContentFilterResults))]
public bool IsFiltered => ContentFilterResults is not null
&& (ContentFilterResults.Hate.Filtered || ContentFilterResults.SelfHarm.Filtered || ContentFilterResults.Violence.Filtered
|| ContentFilterResults.Sexual.Filtered);
/// <summary>
/// When using streaming responses, gets or sets the partial message delta associated with this <see cref="ChatGptChoice"/>.
/// </summary>
/// <see cref="ChatGptRequest.Stream"/>
public ChatGptMessage? Delta { get; set; }
/// <summary>
/// Gets or sets a value specifying why the choice has been returned.
/// </summary>
/// <remarks>
/// Possible values are:
/// <list type="bullet">
/// <item><description>stop: API returned complete model output</description></item>
/// <item><description>length: incomplete model output due to <em>max_tokens</em> parameter or token limit</description></item>
/// <item><description>function_call: the model decided to call a function</description></item>
/// <item><description>content_filter: omitted content due to a flag from content filters</description></item>
/// <item><description>null: API response still in progress or incomplete</description></item>
/// </list>
/// </remarks>
[JsonPropertyName("finish_reason")]
public string FinishReason { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the log probabilities associated with this <see cref="ChatGptChoice"/>.
/// </summary>
/// <seealso cref="ChatGptLogProbability"/>
/// <seealso cref="ChatGptLogProbabilityContent"/>
[JsonPropertyName("logprobs")]
public ChatGptLogProbability? LogProbabilities { get; set; }
}