Skip to main content
iso8583sim.llm.base This module defines the abstract base class for LLM providers, allowing multiple backend implementations (Anthropic, OpenAI, Google, Ollama).

LLMResponse

Response from an LLM provider.

LLMError

Bases: Exception Base exception for LLM-related errors.

ProviderNotAvailableError

Bases: LLMError
Raised when a provider’s dependencies are not installed.

ProviderConfigError

Bases: LLMError Raised when provider configuration is invalid.

GenerationError

Bases: LLMError Raised when message generation fails.

LLMProvider

Bases: ABC Abstract base class for LLM providers. All LLM providers must implement this interface to be compatible with MessageExplainer and MessageGenerator. Example

complete()

Send a prompt to the LLM and return the response text. Parameters
str
required
The user prompt to send
str | None
default:"None"
Optional system prompt for context
str
The LLM’s response text
Raises
  • LLMError: If the API call fails

name

Return the provider name for logging/display.

model

Return the model name being used.

complete_with_metadata()

Send a prompt and return response with metadata. Default implementation wraps complete(). Providers can override for more detailed metadata. Parameters
str
required
The user prompt to send
str | None
default:"None"
Optional system prompt for context
LLMResponse
LLMResponse with content and metadata