Skip to content

Commit

Permalink
Improve instruction string clarity in GetAdditionalJsonResponsePrompt
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rodion-m committed Nov 8, 2023
1 parent 802aa2b commit c83365a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>2.9.2</Version>
<Version>2.9.3</Version>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>12</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ private static TObject DeserializeOrThrow<TObject>(JsonSerializerOptions? jsonDe
private static string GetAdditionalJsonResponsePrompt<TObject>(
string responseFormat, IEnumerable<TObject>? 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;
Expand Down

0 comments on commit c83365a

Please sign in to comment.