From 682b77dcb4d4078a372bad48e0e424ee6a8d797c Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Tue, 1 Oct 2024 11:15:40 -0500 Subject: [PATCH 1/2] Simplify structured outputs sample code --- examples/Chat/Example06_StructuredOutputs.cs | 4 ++-- examples/Chat/Example06_StructuredOutputsAsync.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/Chat/Example06_StructuredOutputs.cs b/examples/Chat/Example06_StructuredOutputs.cs index 37dd7b7cb..718393313 100644 --- a/examples/Chat/Example06_StructuredOutputs.cs +++ b/examples/Chat/Example06_StructuredOutputs.cs @@ -51,12 +51,12 @@ public void Example06_StructuredOutputs() using JsonDocument structuredJson = JsonDocument.Parse(completion.Content[0].Text); - Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}"); + Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer")}"); Console.WriteLine("Reasoning steps:"); foreach (JsonElement stepElement in structuredJson.RootElement.GetProperty("steps").EnumerateArray()) { - Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation").GetString()}"); + Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation")}"); Console.WriteLine($" Output: {stepElement.GetProperty("output")}"); } } diff --git a/examples/Chat/Example06_StructuredOutputsAsync.cs b/examples/Chat/Example06_StructuredOutputsAsync.cs index 6d056b5f5..47ede4913 100644 --- a/examples/Chat/Example06_StructuredOutputsAsync.cs +++ b/examples/Chat/Example06_StructuredOutputsAsync.cs @@ -52,12 +52,12 @@ public async Task Example06_StructuredOutputsAsync() using JsonDocument structuredJson = JsonDocument.Parse(completion.Content[0].Text); - Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}"); + Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer")}"); Console.WriteLine("Reasoning steps:"); foreach (JsonElement stepElement in structuredJson.RootElement.GetProperty("steps").EnumerateArray()) { - Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation").GetString()}"); + Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation")}"); Console.WriteLine($" Output: {stepElement.GetProperty("output")}"); } } From 17f5acf3fc968c90e92aea0270fa37fd20af8cdd Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Tue, 1 Oct 2024 11:32:27 -0500 Subject: [PATCH 2/2] Update README sample --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 019d7fae8..a00a238c0 100644 --- a/README.md +++ b/README.md @@ -342,12 +342,12 @@ ChatCompletion completion = client.CompleteChat(messages, options); using JsonDocument structuredJson = JsonDocument.Parse(completion.Content[0].Text); -Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer").GetString()}"); +Console.WriteLine($"Final answer: {structuredJson.RootElement.GetProperty("final_answer")}"); Console.WriteLine("Reasoning steps:"); foreach (JsonElement stepElement in structuredJson.RootElement.GetProperty("steps").EnumerateArray()) { - Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation").GetString()}"); + Console.WriteLine($" - Explanation: {stepElement.GetProperty("explanation")}"); Console.WriteLine($" Output: {stepElement.GetProperty("output")}"); } ```