Skip to content

Type Alias: GbnfJsonObjectSchema<Keys>

ts
type GbnfJsonObjectSchema<Keys> = {
  type: "object";
  properties: { readonly [key in Keys]: GbnfJsonSchema };
  additionalProperties: boolean | GbnfJsonSchema;
  minProperties: number;
  maxProperties: number;
  required: readonly Keys[];
  description: string;
};

Defined in: utils/gbnfJson/types.ts:81

Type Parameters

Type ParameterDefault type
Keys extends stringstring

Type declaration

type

ts
readonly type: "object";

properties?

ts
readonly optional properties: { readonly [key in Keys]: GbnfJsonSchema };

additionalProperties?

ts
readonly optional additionalProperties: boolean | GbnfJsonSchema;

Unlike the JSON Schema spec, additionalProperties defaults to false to avoid breaking existing code.

minProperties?

ts
readonly optional minProperties: number;

Make sure you define additionalProperties for this to have any effect.

When using minProperties and/or maxProperties, ensure to inform the model as part of the prompt what your expectations are regarding the number of keys in the object. Not doing this may lead to hallucinations.

maxProperties?

ts
readonly optional maxProperties: number;

Make sure you define additionalProperties for this to have any effect.

When using minProperties and/or maxProperties, ensure to inform the model as part of the prompt what your expectations are regarding the number of keys in the object. Not doing this may lead to hallucinations.

required?

ts
readonly optional required: readonly Keys[];

required is always set to all keys in properties, and setting it has no effect.

This limitation is due to how the generation works, and may be fixed in the future.

This key is part of the type to avoid breaking exiting code (though it was never actually used in the past), and will be removed in the future.

Deprecated

description?

ts
readonly optional description: string;

A description of what you expect the model to set this value to.

Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.