Skip to content

API Reference parrot_formdesigner.core.llm_validation

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.core.llm_validation

View source

LLM-assisted answer plausibility configuration and report models (FEAT-649).

Declares the typed FormSchema.llm_validation block, the per-answer verdict and the report returned by AnswerPlausibilityChecker (services/plausibility.py).

Alias FieldType

Re-exported from parrot_formdesigner.core.types.FieldType.

Alias FormField

Re-exported from parrot_formdesigner.core.schema.FormField.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Class LLMValidationConfig

Per-form LLM plausibility settings (FormSchema.llm_validation).

Fields:

Field Type Default Description
enabled bool False
threshold float 0.7
on_error Literal['skip', 'block'] 'skip'
on_implausible Literal['annotate', 'review', 'reject'] 'annotate' What to do with an answer the model judged implausible. annotate (default) stores it with the verdict attached — FEAT-649 behaviour, unchanged; review refuses the submission until the client reconfirms; reject always refuses. Distinct from on_error, which governs LLM unavailability only.
model str | None None
timeout_s float 8.0
max_fields int 50
exclude_field_types list[FieldType]
max_answer_chars int 500 Max characters of a rendered answer placed in the prompt (FEAT-737). Longer text is truncated with a trailing … so the model can see the answer was cut rather than silently judging a fragment as if it were whole.
max_reason_chars int 300 Max characters kept from the model's returned reason (FEAT-737). Bounds what a verbose or adversarial response can persist into the audit record and echo back to the client.

Attribute NOT_EXAMINED_MAX_FIELDS

Type: str

Attribute NOT_EXAMINED_UNRENDERABLE

Type: str

Attribute PLAUSIBILITY_AUDIT_FIELDS

Type: frozenset[str]

Class PlausibilityReport

Outcome of one plausibility batch.

Fields:

Field Type Default Description
status Literal['ok', 'skipped', 'blocked']
reason str | None None
model str | None None
threshold float
latency_ms int | None None
items dict[str, PlausibilityVerdict]
resolved_model str | None None The model that actually answered (AIMessage.model) — FEAT-732. model above is what the config REQUESTED and may be None (client default). This is what RESPONDED. None only when no LLM call was made.
provider str | None None The provider that answered (AIMessage.provider).
usage dict[str, Any] | None None Token usage of the call (AIMessage.usage), JSON-dumped.
not_examined dict[str, str] Eligible field ids the model never saw, by reason code (FEAT-737). Keys are field ids; values are NOT_EXAMINED_MAX_FIELDS or NOT_EXAMINED_UNRENDERABLE. Empty on a skipped/blocked report — those statuses already say the whole batch went unexamined. A status="ok" report with a non-empty map means PARTIAL coverage: items is authoritative only for the field ids absent from this map.

Class PlausibilityVerdict

LLM judgement for one (question, answer) pair.

Fields:

Field Type Default Description
plausible bool
confidence float
reason str

Function implausible_fields

Return sorted field ids whose verdict trips the enforcement gate.

implausible_fields(report: PlausibilityReport) -> list[str]

Parameter Type Default Description
report PlausibilityReport One plausibility batch outcome.

Returns: list[str] — Sorted field ids for implausible verdicts. Reports whose status is not "ok" remain on the LLM-unavailability path and return no ids.

Function llm_validation_enabled

Return whether field takes part in plausibility checking.

field.llm_validation wins when not None; otherwise inherit form.llm_validation.enabled (False when the block is absent).

llm_validation_enabled(form: FormSchema, field: FormField) -> bool

Parameter Type Default Description
form FormSchema
field FormField

Returns: bool

Function wire_report

Dump report for a client-facing response, without audit-only fields.

wire_report(report: PlausibilityReport, **dump_kwargs: Any) -> dict[str, Any]

Parameter Type Default Description
report PlausibilityReport The plausibility report to serialize.
**dump_kwargs Any {} Forwarded to model_dump unchanged. An exclude set is honoured and widened.

Returns: dict[str, Any] — The dumped report minus PLAUSIBILITY_AUDIT_FIELDS.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally