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

Properties

type

ts
readonly type: "object";

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


properties?

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

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


additionalProperties?

ts
readonly optional additionalProperties: boolean | GbnfJsonSchema;

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

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


minProperties?

ts
readonly optional minProperties: number;

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

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;

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

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[];

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

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;

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

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.