From c83365a7907939f0104e999589454959792799f6 Mon Sep 17 00:00:00 2001 From: Rodion Mostovoi Date: Wed, 8 Nov 2023 16:38:07 +0800 Subject: [PATCH] Improve instruction string clarity in GetAdditionalJsonResponsePrompt The commit changes the response string in the GetAdditionalJsonResponsePrompt method. The previous phrasing was potentially unclear, so it has been adjusted to more explicitly require RFC8259 compliant JSON and to remove unneeded verbiage in the examples section. This is intended to improve user comprehension and adhere more strictly to JSON conventions. --- src/Directory.Build.props | 2 +- .../OpenAiClientExtensions.GetStructuredResponse.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index b900ed4..14cd573 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,6 @@ - 2.9.2 + 2.9.3 enable enable 12 diff --git a/src/modules/OpenAI.ChatGpt.Modules.StructuredResponse/OpenAiClientExtensions.GetStructuredResponse.cs b/src/modules/OpenAI.ChatGpt.Modules.StructuredResponse/OpenAiClientExtensions.GetStructuredResponse.cs index abaf2d3..e32f5e6 100644 --- a/src/modules/OpenAI.ChatGpt.Modules.StructuredResponse/OpenAiClientExtensions.GetStructuredResponse.cs +++ b/src/modules/OpenAI.ChatGpt.Modules.StructuredResponse/OpenAiClientExtensions.GetStructuredResponse.cs @@ -193,14 +193,14 @@ private static TObject DeserializeOrThrow(JsonSerializerOptions? jsonDe private static string GetAdditionalJsonResponsePrompt( string responseFormat, IEnumerable? examples, JsonSerializerOptions? jsonSerializerOptions) { - var res = $"\n\nYour response MUST be STRICTLY compact JSON with escaped strings. " + - $"Here is the response structure (JSON Schema): \n```json{responseFormat}```"; + var res = $"\n\nYour output must be strictly in valid, readable, iterable RFC8259 compliant JSON without any extra text. " + + $"Here is the output structure (JSON Schema):\n```json\n{responseFormat}\n```"; if (examples is not null) { jsonSerializerOptions ??= JsonDefaultSerializerOptions; var examplesString = string.Join("\n", examples.Select(it => JsonSerializer.Serialize(it, jsonSerializerOptions))); - res += $"\n\nHere are some examples:\n```json\n{examplesString}\n```"; + res += $"\n\nExamples:\n```json\n{examplesString}\n```"; } return res;