aeat.application.ledger._vision_classifier module

On-host vision evidence reader: classify/split from an attached invoice image.

Reads scanned or image evidence with a LOCAL Ollama vision model entirely on the host (sensitive-financial-data-secure-storage-only): the in-memory base64 images are sent over loopback HTTP to the local model; nothing is written to disk and nothing leaves the machine. This is the ADR’s default, gestor-allowed posture for scanned/image evidence – distinct from the consent-gated cloud subprocess text path used for text-layer PDFs.

The prompt and the allow-list-guarded response parsing are the same domain contracts the subprocess classifier uses (parse_response(), parse_split_response(), PromptSpec); only the transport – a local vision model fed in-memory images – differs, so the model still selects only classification / category / iva_category and never emits a regulated number.

class LocalVisionLLMClassifier(*, spec, model=None, client=None, settings=None)[source]

Bases: object

Classify or split a transaction from an attached invoice image, on-host.

Parameters:
  • spec (PromptSpec) – The prompt spec carrying the registry-grounded category / IVA-category allow-lists (the same spec the subprocess classifier uses).

  • model (str | None) – Local Ollama vision model identifier; defaults to Settings.aeat_llm_ollama_vision_model.

  • client (LLMClient | None) – Injected LLMClient (dependency injection for tests); default-constructed against the resolved settings otherwise.

  • settings (Settings | None) – Injected settings; defaults to load_settings().

property decided_by: str

Provenance stamp recorded as classified_by (distinct from cloud subprocess).

classify(transaction, *, evidence_images)[source]

Read the attached invoice image with the local vision model and classify.

Parameters:
  • transaction (Transaction) – The transaction to classify.

  • evidence_images (tuple[str, ...]) – In-memory base64 page/image renders of the evidence.

Return type:

LLMClassificationResponse

Returns:

A validated LLMClassificationResponse (allow-list-guarded).

propose_split(transaction, *, evidence_images)[source]

Read the attached invoice image with the local vision model and propose a split.

Parameters:
  • transaction (Transaction) – The transaction to split.

  • evidence_images (tuple[str, ...]) – In-memory base64 page/image renders of the evidence.

Return type:

LLMSplitResponse

Returns:

A validated LLMSplitResponse (allow-list-guarded).