local_structured
Generate JSON-schema-compliant outputs from local models, with automatic validation and retries on invalid results.
Instructions
Has a local model return a result that conforms to a JSON schema.
Uses the respective backend's schema enforcement (Ollama's 'format' field,
vLLM's 'response_format' with 'json_schema') and then additionally validates
the answer against the schema itself. If the output does not satisfy the
schema, it retries up to twice, passing the model the concrete violations.
Only then an error, but then with the invalid raw output, so it is visible
what went wrong.
Args:
model: Model name, for example 'llama3.2:3b'.
prompt: Instruction on what should be extracted from which text.
schema: JSON schema of the desired result (object with 'type', 'properties', ...).
system: Optional role/behavior instruction.
think: Enables the model's reasoning trace. Off by default, because the
reasoning trace otherwise consumes the answer's token budget. Only
for models with the 'thinking' capability.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | ||
| think | No | ||
| prompt | Yes | ||
| schema | Yes | ||
| system | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||