Skip to content

Commit 4d10d21

Browse files
committed
Feedback
1 parent f1fdd73 commit 4d10d21

6 files changed

+39
-12
lines changed

examples/Chat/Example10_AdditionalProperties.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ namespace OpenAI.Examples;
88

99
public partial class ChatExamples
1010
{
11-
[Test]
1211
public void Example10_AdditionalProperties()
1312
{
1413
ChatClient client = new(model: "gpt-5", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
1514

16-
// You can use the Patch property to set additional properties in the request
15+
// Add extra request fields using Patch.
16+
// Patch lets you set fields that aren’t modeled on ChatCompletionOptions in the request payload.
17+
// See the API docs https://platform.openai.com/docs/api-reference/chat/create for supported additional fields.
1718
ChatCompletionOptions options = new();
1819
options.Patch.Set("$.reasoning_effort"u8, "minimal");
1920

20-
ChatCompletion completion = client.CompleteChat([new UserChatMessage("Say 'this is a test.'")], options);
21+
ChatCompletion completion = client.CompleteChat(
22+
[new UserChatMessage("Say 'this is a test.'")],
23+
options);
2124

2225
Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
2326

24-
// You can also read additional properties back from the response
27+
// Read extra fields from the response via Patch.
28+
// The service returns a field named `service_tier` that isn’t modeled on ChatCompletion.
29+
// You can access its value by using the path with Patch.
30+
// See the API docs https://platform.openai.com/docs/api-reference/chat/object for supported additional fields.
2531
var serviceTier = completion.Patch.GetString("$.service_tier"u8);
2632
Console.WriteLine($"service_tier={serviceTier}");
2733
}

examples/Chat/Example10_AdditionalPropertiesAsync.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@ public async Task Example10_AdditionalPropertiesAsync()
1414
{
1515
ChatClient client = new(model: "gpt-5", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
1616

17-
// You can use the Patch property to set additional properties in the request
17+
// Add extra request fields using Patch.
18+
// Patch lets you set fields that aren’t modeled on ChatCompletionOptions in the request payload.
19+
// See the API docs https://platform.openai.com/docs/api-reference/chat/create for supported additional fields.
1820
ChatCompletionOptions options = new();
1921
options.Patch.Set("$.reasoning_effort"u8, "minimal");
2022

2123
ChatCompletion completion = await client.CompleteChatAsync([new UserChatMessage("Say 'this is a test.'")], options);
2224

2325
Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}");
2426

25-
// You can also read additional properties back from the response
27+
// Read extra fields from the response via Patch.
28+
// The service returns a field named `service_tier` that isn’t modeled on ChatCompletion.
29+
// You can access its value by using the path with Patch.
30+
// See the API docs https://platform.openai.com/docs/api-reference/chat/object for supported additional fields.
2631
var serviceTier = completion.Patch.GetString("$.service_tier"u8);
2732
Console.WriteLine($"service_tier={serviceTier}");
2833
}

examples/Responses/Example07_InputAdditionalProperties.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public void Example07_InputAdditionalProperties()
1616
{
1717
OpenAIResponseClient client = new(model: "gpt-5", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
1818

19-
// You can use the Patch property to set additional properties in the request
19+
// Add extra request fields using Patch.
20+
// Patch lets you set fields like `reasoning.effort` and `text.verbosity` that aren’t modeled on ResponseCreationOptions in the request payload.
21+
// See the API docs https://platform.openai.com/docs/api-reference/responses/create for supported additional fields.
2022
ResponseCreationOptions options = new();
2123
options.Patch.Set("$.reasoning.effort"u8, "high");
2224
options.Patch.Set("$.text.verbosity"u8, "medium");
@@ -25,7 +27,10 @@ public void Example07_InputAdditionalProperties()
2527

2628
Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}");
2729

28-
// You can also read additional properties back from the response
30+
// Read extra fields from the response via Patch.
31+
// The service returns fields like `reasoning.effort` and `text.verbosity` that aren’t modeled on OpenAIResponse.
32+
// You can access their values by using the path with Patch.
33+
// See the API docs https://platform.openai.com/docs/api-reference/responses/object for supported additional fields.
2934
var effort = response.Patch.GetString("$.reasoning.effort"u8);
3035
var verbosity = response.Patch.GetString("$.text.verbosity"u8);
3136
Console.WriteLine($"effort={effort}, verbosity={verbosity}");

examples/Responses/Example07_InputAdditionalPropertiesAsync.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public async Task Example07_InputAdditionalPropertiesAsync()
1717
{
1818
OpenAIResponseClient client = new(model: "gpt-5", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
1919

20-
// You can use the Patch property to set additional properties in the request
20+
// Add extra request fields using Patch.
21+
// Patch lets you set fields like `reasoning.effort` and `text.verbosity` that aren’t modeled on ResponseCreationOptions in the request payload.
22+
// See the API docs https://platform.openai.com/docs/api-reference/responses/create for supported additional fields.
2123
ResponseCreationOptions options = new();
2224
options.Patch.Set("$.reasoning.effort"u8, "high");
2325
options.Patch.Set("$.text.verbosity"u8, "medium");
@@ -26,7 +28,10 @@ public async Task Example07_InputAdditionalPropertiesAsync()
2628

2729
Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}");
2830

29-
// You can also read additional properties back from the response
31+
// Read extra fields from the response via Patch.
32+
// The service returns fields like `reasoning.effort` and `text.verbosity` that aren’t modeled on OpenAIResponse.
33+
// You can access their values by using the path with Patch.
34+
// See the API docs https://platform.openai.com/docs/api-reference/responses/object for supported additional fields.
3035
var effort = response.Patch.GetString("$.reasoning.effort"u8);
3136
var verbosity = response.Patch.GetString("$.text.verbosity"u8);
3237
Console.WriteLine($"effort={effort}, verbosity={verbosity}");

examples/Responses/Example08_OutputAdditionalProperties.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public void Example08_OutputAdditionalProperties()
3535
using FileStream stream = File.OpenWrite($"{Guid.NewGuid()}.png");
3636
bytes.ToStream().CopyTo(stream);
3737

38-
// You can use the Patch property to read additional properties from the response
38+
// Read extra fields from the response via Patch.
39+
// The service returns fields like `output_format` and `quality` that aren’t modeled on ImageGenerationCallResponseItem.
40+
// You can access their values by using the path with Patch.
41+
// See the API docs https://platform.openai.com/docs/api-reference/responses/object for supported additional fields.
3942
var outputFormat = imageGenResponse.Patch.GetString("$.output_format"u8);
4043
var quality = imageGenResponse.Patch.GetString("$.quality"u8);
4144
var size = imageGenResponse.Patch.GetString("$.size"u8);

examples/Responses/Example08_OutputAdditionalPropertiesAsync.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public async Task Example08_OutputAdditionalPropertiesAsync()
3636
using FileStream stream = File.OpenWrite($"{Guid.NewGuid()}.png");
3737
bytes.ToStream().CopyTo(stream);
3838

39-
// You can use the Patch property to read additional properties from the response
39+
// Read extra fields from the response via Patch.
40+
// The service returns fields like `output_format` and `quality` that aren’t modeled on ImageGenerationCallResponseItem.
41+
// You can access their values by using the path with Patch.
42+
// See the API docs https://platform.openai.com/docs/api-reference/responses/object for supported additional fields.
4043
var outputFormat = imageGenResponse.Patch.GetString("$.output_format"u8);
4144
var quality = imageGenResponse.Patch.GetString("$.quality"u8);
4245
var size = imageGenResponse.Patch.GetString("$.size"u8);

0 commit comments

Comments
 (0)