Skip to content

Commit 682b77d

Browse files
committed
Simplify structured outputs sample code
1 parent c28661f commit 682b77d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/Chat/Example06_StructuredOutputs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public void Example06_StructuredOutputs()
5151

5252
using JsonDocument structuredJson = JsonDocument.Parse(completion.Content[0].Text);
5353

54-
Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}");
54+
Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer")}");
5555
Console.WriteLine("Reasoning steps:");
5656

5757
foreach (JsonElement stepElement in structuredJson.RootElement.GetProperty("steps").EnumerateArray())
5858
{
59-
Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation").GetString()}");
59+
Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation")}");
6060
Console.WriteLine($" Output: {stepElement.GetProperty("output")}");
6161
}
6262
}

examples/Chat/Example06_StructuredOutputsAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ public async Task Example06_StructuredOutputsAsync()
5252

5353
using JsonDocument structuredJson = JsonDocument.Parse(completion.Content[0].Text);
5454

55-
Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}");
55+
Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer")}");
5656
Console.WriteLine("Reasoning steps:");
5757

5858
foreach (JsonElement stepElement in structuredJson.RootElement.GetProperty("steps").EnumerateArray())
5959
{
60-
Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation").GetString()}");
60+
Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation")}");
6161
Console.WriteLine($" Output: {stepElement.GetProperty("output")}");
6262
}
6363
}

0 commit comments

Comments
 (0)