An unofficial OpenAI Unity Package that aims to help you use OpenAI API directly in Unity Game engine.
648
stars
144
forks
source link
Support JSON response: CreateChatCompletionRequest class supports response_format field #116
Open
redclock opened 4 months ago
Supports specifying the response return format, either JSON or text. Address #105
See OpenAI API document of response_format parameter GPT-4-turbo and GPT-3.5-turbo-1106 support this parameter.
Specifying the return result as JSON is useful for workflows.
Code sample:
Response:
If you removed the
ResponseFormat = ResponseFormat.JsonObject
, the response becomes:Note: According to the document, when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message.