aeat.adapters.outbound.llm._models module¶
Strict Pydantic models for the LLM package.
The public adapters.outbound.llm facade re-exports these records.
LLMRequest,
LLMResponse, and
LLMProvider form the
LLMClient boundary.
CachedEntry,
CacheKey, and
CacheStats support
LLMCache, while
UsageRecord and
UsageSummary support
UsageRecorder. Prompt definitions are
managed through PromptRegistry; validation
helpers raise LLMValidationError.
- class LLMProvider(*values)[source]¶
Bases:
StrEnumSupported providers selected by
LLMClient.- ANTHROPIC¶
- OPENAI¶
- GEMINI¶
- LOCAL¶
- class MultimodalImageInput(**data)[source]¶
Bases:
BaseModelOne on-host-prepared image attached to a multimodal LLM request.
Transient and in-memory only. Carries the base64-encoded image bytes the provider adapter forwards to a local vision model and the content address (an attachment-store SHA-256) that
LLMCachefolds intoCacheKey. The base64 payload is never persisted – only its content address enters the cache key (sensitive-financial-data-secure-storage-only).- content_sha256: str¶
- base64_data: str¶
- class LLMRequest(**data)[source]¶
Bases:
BaseModelUser-facing completion request accepted by
LLMClient.Provider and model override fields select
LLMProvidervalues for one call, andimagescarries transientMultimodalImageInputpayloads for local vision flows.- Parameters:
prompt (str)
system (str | None)
max_tokens (int | None)
temperature (float | None)
language (str | None)
cache_key (str | None)
provider_override (LLMProvider | None)
model_override (str | None)
images (tuple[MultimodalImageInput, ...])
- prompt: str¶
- system: str | None¶
- max_tokens: int | None¶
- temperature: float | None¶
- language: str | None¶
- cache_key: str | None¶
- provider_override: LLMProvider | None¶
- model_override: str | None¶
- images: tuple[MultimodalImageInput, ...]¶
- classmethod validate_prompt(value)[source]¶
Ensure prompts are not empty or whitespace-only.
- Raises:
LLMValidationError – When the
prompt is blank after trimming. –
- Return type:
- Parameters:
value (str)
- class LLMResponse(**data)[source]¶
Bases:
BaseModelCompletion response returned by
complete().Responses are persisted inside
CachedEntryrecords and converted intoUsageRecordvalues for cost tracking.- Parameters:
- text: str¶
- provider: LLMProvider¶
- model: str¶
- input_tokens: int¶
- output_tokens: int¶
- cost_estimate_usd: Decimal¶
- cache_hit: bool¶
- created_at: datetime¶
- request_id: str¶
- class PromptDefinition(**data)[source]¶
Bases:
BaseModelPrompt metadata stored by
PromptRegistry.- Parameters:
- id: str¶
- version: int¶
- template: str¶
- expected_output_schema: type[BaseModel] | None¶
- description: str¶
- class PromptRegistry(**data)[source]¶
Bases:
BaseModelRegistry of versioned
PromptDefinitionvalues.- Parameters:
definitions (dict[str, PromptDefinition])
- definitions: dict[str, PromptDefinition]¶
- register(definition)[source]¶
Add or replace a prompt definition.
- Return type:
- Parameters:
definition (PromptDefinition)
- get(prompt_id, version=None)[source]¶
Return a
PromptDefinitionby id and optional version.- Return type:
- Parameters:
- classmethod seeded()[source]¶
Return a default
PromptRegistry.- Return type:
- class CachedEntry(**data)[source]¶
Bases:
BaseModelEncrypted cache record persisted by
LLMCache.- Parameters:
provider (LLMProvider)
model (str)
prompt_hash (str)
args_hash (str)
response (LLMResponse)
created_at (datetime)
- provider: LLMProvider¶
- model: str¶
- prompt_hash: str¶
- args_hash: str¶
- response: LLMResponse¶
- created_at: datetime¶
- class UsageRecord(**data)[source]¶
Bases:
BaseModelAppend-only usage record persisted by
UsageRecorder.- Parameters:
- prompt_id: str¶
- caller: str¶
- text: str¶
- provider: LLMProvider¶
- model: str¶
- input_tokens: int¶
- output_tokens: int¶
- cost_estimate_usd: Decimal¶
- cache_hit: bool¶
- created_at: datetime¶
- request_id: str¶
- class Translation(**data)[source]¶
Bases:
BaseModelTranslation response built on top of
LLMResponse.- Parameters:
- text: str¶
- source_lang: str¶
- target_lang: str¶
- provider: LLMProvider¶
- model: str¶
- input_tokens: int¶
- output_tokens: int¶
- created_at: datetime¶
- class CacheKey(**data)[source]¶
Bases:
BaseModelDerived cache key used by
LLMCache.- Parameters:
provider (LLMProvider)
model (str)
prompt_hash (str)
args_hash (str)
- provider: LLMProvider¶
- model: str¶
- prompt_hash: str¶
- args_hash: str¶
- class CacheStats(**data)[source]¶
Bases:
BaseModelBasic
LLMCachestatistics for CLI reporting.- entries: int¶
- total_bytes: int¶