You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: OpenAI_API/Chat/ChatRequest.cs
+41-1Lines changed: 41 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
1
usingNewtonsoft.Json;
2
+
usingNewtonsoft.Json.Linq;
3
+
usingOpenAI_API.Models;
2
4
usingSystem;
3
5
usingSystem.Collections.Generic;
6
+
usingSystem.ComponentModel;
7
+
usingSystem.IO;
4
8
usingSystem.Linq;
5
9
usingSystem.Text;
6
10
@@ -119,6 +123,28 @@ public string StopSequence
119
123
[JsonProperty("user")]
120
124
publicstringuser{get;set;}
121
125
126
+
/// <summary>
127
+
/// An object specifying the format that the model must output. Setting to <see cref="ResponseFormats.JsonObject"/> enables JSON mode, which guarantees the message the model generates is valid JSON, assuming that the <see cref="ChatChoice.FinishReason"/> is not "length".
128
+
/// Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request.Also note that the message content may be partially cut off if `finish_reason= "length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
129
+
/// </summary>
130
+
[JsonIgnore]
131
+
publicstringResponseFormat{get;set;}="text";
132
+
133
+
/// <summary>
134
+
/// This is only used for serializing the request into JSON, do not use it directly.
newChatMessage(ChatMessageRole.System,"You are a helpful assistant designed to output JSON."),
471
+
newChatMessage(ChatMessageRole.User,"Who won the world series in 2020? Return JSON of a 'wins' dictionary with the year as the numeric key and the winning team as the string value.")
0 commit comments