aeat.adapters.outbound.llm._providers.local module¶
Local provider adapter for Ollama-compatible runtimes.
Speaks the Ollama /api/chat endpoint (resolved per call from
Settings.aeat_llm_ollama_chat_url) and adapts its response into the
ProviderCompletion shape.
The adapter assumes the runtime is reachable on localhost; remote Ollama
deployments are out of scope.
For multimodal evidence, rasterise_pdf_pages_to_base64_png() renders an
in-memory PDF to base64 PNG pages fully on-host so a local vision model can read
a scan-only invoice; the adapter forwards those base64 images on the Ollama
images message field. No file is written and nothing leaves the host
(sensitive-financial-data-secure-storage-only).
- rasterise_pdf_pages_to_base64_png(pdf_bytes, *, scale=2.0)[source]¶
Rasterise each page of an in-memory PDF to a base64-encoded PNG, on-host.
Renders every page in process memory via pypdfium2 and Pillow so a local vision model can read a scan-only or image-only PDF that has no extractable text layer. Nothing is written to disk and nothing leaves the host (
sensitive-financial-data-secure-storage-only).
- class LocalAdapter(timeout_s)[source]¶
Bases:
_ProviderAdapterProvider adapter that invokes a local Ollama-compatible HTTP endpoint.
- Parameters:
timeout_s (int)
-
provider:
LLMProvider¶
- async complete(request)[source]¶
Execute a chat completion request against the local endpoint.
- Parameters:
request (
ProviderRequest) – Normalized provider request.- Return type:
- Returns:
ProviderCompletioncontaining the trimmed assistant message and reported token counts.- Raises:
LLMProviderError – When the runtime returns a non-2xx HTTP error status.