TsgcAIDocumentExtractor › Properties › Schema
JSON Schema of the data to extract, used when Preset is dpCustom.
property Schema: TStringList read FSchema write SetSchema;
—
The text of the list is a JSON Schema whose root is an object. It describes only your data: the component wraps it in an answer object with a data member that follows the schema and, when IncludeConfidence is True, a confidence array. Schema is ignored when Preset is not dpCustom. An empty or invalid Schema raises EsgcAIDocumentExtractor before any request is sent.
When the provider is OpenAI the schema is sent in strict mode, so it must follow the strict rules:
"additionalProperties": false.required.["string","null"].The answer is validated locally against a subset of JSON Schema: type (object, array, string, number, integer, boolean, null and type arrays such as ["string","null"]), properties, required, items and enum, recursing into nested objects and arrays. Other keywords are sent to the provider but not checked locally.
Tip: GetPresetSchema returns a strict compatible schema you can copy into Schema and adapt.
oExtractor.Preset := dpCustom;
oExtractor.Schema.Text :=
'{"type":"object","additionalProperties":false,' +
'"required":["order_number","total"],"properties":{' +
'"order_number":{"type":["string","null"]},' +
'"total":{"type":["number","null"]}}}';