aeat.adapters.outbound.llm package

Public facade for outbound model-provider completion adapters.

The package root defines the __all__ contract for public imports. Use these top-level re-exports for LLMClient, LLMRequest, LLMResponse, LLMProvider, cache records (LLMCache, CacheKey, CacheStats, CachedEntry), prompt types (PromptRegistry and PromptDefinition), usage records (UsageRecorder, UsageRecord, and UsageSummary), model records (Translation and MultimodalImageInput), rasterisation, and exported error types.

The async-first LLMClient.complete() flow reads LLMCache before a provider call, writes content-addressed encrypted cache entries on misses, records usage on hits and misses, and returns LLMResponse. Cache types include CacheKey, CacheStats, and CachedEntry; persisted cache data is encrypted secure-object storage, not plaintext files.

Prompt handling uses PromptRegistry and PromptDefinition for versioned prompt definitions/templates. UsageRecorder persists redacted UsageRecord values to encrypted secure-object storage and produces UsageSummary reports. LLMRunTelemetryRecorder persists local-only LLMRunRecord run-timing/outcome metadata (never prompt or response text) and produces LLMRunTelemetrySummary reports, backing the aeat app diagnostics run-health operator surface. Strict model types include Translation and transient MultimodalImageInput, whose base64 bytes are not persisted; only content SHA participates in cache keys.

Use rasterise_pdf_pages_to_base64_png() for in-memory, on-host PDF-to-PNG rasterisation for local vision inputs. Exported exceptions include LLMError, LLMCacheError, LLMConfigError, LLMPdfRasterisationError, LLMProviderError, and LLMRateLimitError. Importing this outbound adapter must remain silent.

Examples

Issue a completion via the high-level client:

>>> import asyncio
>>> from aeat.adapters.outbound.llm import LLMClient, LLMRequest
>>> async def main() -> None:
...     client = LLMClient()
...     response = await client.complete(
...         LLMRequest(prompt="Summarize the requested modelo in one sentence.")
...     )
...     # response.text contains the completion; print in real usage
>>> # asyncio.run(main())  # requires a live LLM provider; omitted from doctest

Subpackages

Submodules