JSON Mode
Some models support forcing the output format to a JSON object, like the JSON Object mode of OpenAI.
The generated file name will be [spec].[template].json
.
Schema validation
You can specify a schema through responseSchema
which will automatically turn on the JSON mode. The output will be validated against the schema, and GenAIScript will attempt to repair the output if it is not valid. The script will fail if the output does not match the schema.
You can also provide an example of object and GenAIScript will generate the schema for you.
Inline schemas
You can also specify the schema inline in the script and use a mixed markdown/data that GenAIScript will parse.
Structured Output
Recent models have added a structured output mode that is more strict than JSON mode. This mode is enabled by setting responseType
to json_schema
.