IChatGptSchema is a type schema info for OpenAI function calling. The type
name "ChatGpt" is intentionally used to avoid confusion with "OpenAPI"
specification, even though this is designed for OpenAI models.
IChatGptSchema basically follows the JSON schema definition of the OpenAPI
v3.1 specification; OpenApiV3_1.IJsonSchema. However, it deviates from
the standard JSON schema specification and omits many features when used in
IChatGptSchema.IConfig.strict mode for OpenAI function calling.
IChatGptSchema supports all JSON schema features through workaround
expressions using JSDoc tags in the description property, so using
IChatGptSchema does not degrade function calling performance even in strict
mode.
Here is the list of how IChatGptSchema is different with the OpenAPI v3.1
JSON schema:
Also, OpenAI has banned the following constraint properties. Instead,
IChatGptSchema fills the IChatGptSchema.description property with
workaround expressions using JSDoc tags like "@format uuid" to convey these
constraints:
Specified not only by official documentation, but also by
experimental validation. Therefore, definitions may be inaccurate or
change in the future. If you find wrong or outdated definitions,
please report via issue.
Type schema info for OpenAI function calling.
IChatGptSchemais a type schema info for OpenAI function calling. The type name "ChatGpt" is intentionally used to avoid confusion with "OpenAPI" specification, even though this is designed for OpenAI models.IChatGptSchemabasically follows the JSON schema definition of the OpenAPI v3.1 specification; OpenApiV3_1.IJsonSchema. However, it deviates from the standard JSON schema specification and omits many features when used in IChatGptSchema.IConfig.strict mode for OpenAI function calling.IChatGptSchemasupports all JSON schema features through workaround expressions using JSDoc tags in thedescriptionproperty, so usingIChatGptSchemadoes not degrade function calling performance even in strict mode.Here is the list of how
IChatGptSchemais different with the OpenAPI v3.1 JSON schema:Decompose mixed type: OpenApiV3_1.IJsonSchema.IMixed
Resolve nullable property: OpenApiV3_1.IJsonSchema.__ISignificant.nullable
Tuple type is banned: OpenApiV3_1.IJsonSchema.ITuple.prefixItems
Constant type is banned: OpenApiV3_1.IJsonSchema.IConstant
Merge OpenApiV3_1.IJsonSchema.IOneOf to IChatGptSchema.IAnyOf
Merge OpenApiV3_1.IJsonSchema.IAllOf to IChatGptSchema.IObject
Merge OpenApiV3_1.IJsonSchema.IRecursiveReference to IChatGptSchema.IReference
When IChatGptSchema.IConfig.strict mode:
Compared to OpenApi.IJsonSchema, the emended JSON schema specification:
IChatGptSchema.IAnyOf instead of OpenApi.IJsonSchema.IOneOf
IChatGptSchema.IParameters.$defs instead of OpenApi.IComponents.schemas
IChatGptSchema.IString.enum instead of OpenApi.IJsonSchema.IConstant
IChatGptSchema.additionalProperties is fixed to
falsein strict modeIChatGptSchema.properties and IChatGptSchema.required are always defined
No tuple type OpenApi.IJsonSchema.ITuple support
When IChatGptSchema.IConfig.strict mode:
For reference, if you compose the
IChatGptSchematype with the IChatGptSchema.IConfig.referencefalseoption (default isfalse), only recursively named types are archived into the IChatGptSchema.IParameters.$defs, and others are escaped from the IChatGptSchema.IReference type.Also, OpenAI has banned the following constraint properties. Instead,
IChatGptSchemafills the IChatGptSchema.description property with workaround expressions using JSDoc tags like"@format uuid"to convey these constraints:Additionally, OpenAI cannot define the IChatGptSchema.description property for the IChatGptSchema.IReference type, and does not understand encapsulation of the IChatGptSchema.IAnyOf type. Therefore, the IChatGptSchema.description is written to the parent object type, not the reference type.