hexthedev/OpenAi-Api-Unity

Input using basic multiline syntax not supported when converting JSON

Closed this issue · 1 comments

The following returns an unsupported media type error when sending prompts to OpenAI. Probably an issue with how the string is being processed to be json compatible and the way escape characters are handled in multiline strings in C#.

const string cPromptPrefix = @"Translate user prompts about cubes to XML

The plane's size  = 6 by 6. Cubes can be placed anywhere on the plane, with coordinates ranging (-6, -6) to (6, 6). The positive y axis points to the top of the plane.

User: I want one cube in the middle of the plane
Output:
<Cubes>
<Cube position=""0,0"" />
</Cubes>
###
User: I want a line of three cubes across the top of the plane, 
Output:
<Cubes>
<Cube position=""-1, 5"" />
<Cube position=""-0 5"" />
<Cube position=""1, 5"" />
</Cubes>
###
User: I want a circle made out of 6 cubes slightly left of the center of the plane
Output: 
<Cubes>
<Cube position=""-4, 0"" />
<Cube position=""-1, 0"" />
<Cube position=""-3.5, 1.5"" />
<Cube position=""-1.5, 1.5"" />
<Cube position=""-3.5, -1.5"" />
<Cube position=""-1.5, -1.5"" />
</Cubes>
###
User: ";

Did a test and debugged. Found that the " escape charcter was not properly processed in the JSON Builder. Fixed.