Skip to main content

Interface: ParseJsonOptions<_T>

Defined in: packages/agentos/src/cognition/nlp/ai_utilities/IUtilityAI.ts:175

Options for safe JSON parsing.

Type Parameters​

_T​

_T = any

Properties​

attemptFixWithLLM?​

optional attemptFixWithLLM: boolean

Defined in: packages/agentos/src/cognition/nlp/ai_utilities/IUtilityAI.ts:177

If true, attempts to use an LLM to fix or extract JSON if standard parsing fails.


llmModelIdForFix?​

optional llmModelIdForFix: string

Defined in: packages/agentos/src/cognition/nlp/ai_utilities/IUtilityAI.ts:179

The model a repair calls. LLMUtilityAI: else its jsonFixerModelId, else its defaultModelId.


llmProviderIdForFix?​

optional llmProviderIdForFix: string

Defined in: packages/agentos/src/cognition/nlp/ai_utilities/IUtilityAI.ts:181

The provider a repair calls. LLMUtilityAI: else its defaultProviderId.


maxRepairAttempts?​

optional maxRepairAttempts: number

Defined in: packages/agentos/src/cognition/nlp/ai_utilities/IUtilityAI.ts:197

LLMUtilityAI: how many repairs to try, each on the text the last one answered, while a repair does not parse or fails targetSchema. 1 unless it is a whole number of 1 or more, so Infinity is 1 too.


targetSchema?​

optional targetSchema: JSONSchemaObject

Defined in: packages/agentos/src/cognition/nlp/ai_utilities/IUtilityAI.ts:192

Optional JSON schema (draft-07) to validate the parsed object against, with Ajv. The standard formats are checked (date-time, email, uri and the others of ajv-formats), a keyword Ajv does not know is passed over, as JSON Schema says, and so is a format it does not know, and a value is coerced to the type its schema names where it can ("5" to 5) in the value answered. The schema may be built anew for every call, under the same $id too. StatisticalUtilityAI answers null for a value that fails it. LLMUtilityAI sends a value that fails it for repair as it sends a text that does not parse, names the schema (and a parsed value's errors) in the repair request, and answers null when no repair passes it. No value passes a schema Ajv cannot compile, a schema under the draft-07 meta-schema's $id or a schema marked $async: both classes answer null, and LLMUtilityAI asks for no repair.