ai_sentinel.llm.BaseLLMClient

class ai_sentinel.llm.BaseLLMClient(api_key: str, model: str, timeout: float | None = 30.0, **kwargs)

Abstract Base Class for LLM Clients

__init__(api_key: str, model: str, timeout: float | None = 30.0, **kwargs)

Methods

__init__(api_key, model[, timeout])

generate_text(prompt[, system_prompt, ...])

Generate a response from LLM based on the prompt and optional inputs (sync wrapper).

generate_text_async(prompt[, system_prompt, ...])

Generate a response from LLM based on the prompt and optional inputs (async).

validate()

Validate the provided API key by making a call to the provider (sync wrapper).

validate_async()

Validate the provided API key by making a call to the provider (async).

Attributes

info

Return clean information about the LLM Client configuration.

provider_name

Get the provider name

generate_text(prompt: str, system_prompt: str | None = None, context: list[dict[str, str]] | None = None, temperature: float | None = 0.7, **kwargs) LLMResponse

Generate a response from LLM based on the prompt and optional inputs (sync wrapper).

This is a synchronous wrapper around the async method that is safe to run in any environment, including Jupyter notebooks.

abstract async generate_text_async(prompt: str, system_prompt: str | None = None, context: list[dict[str, str]] | None = None, temperature: float | None = 0.7, **kwargs) LLMResponse

Generate a response from LLM based on the prompt and optional inputs (async).

Warning: Implementations uses deprecated function “datetime.utcnow()”

Parameters: prompt (str): User input system_prompt (Optional[str]): System prompt to give the LLM as it’s role | default = None context (Optional[list[dict[str,str]]]): Conversation history | default = None temperature (Optional[float]): What sampling temperature to use | default = 0.7 **kwargs: Handles structured output ( ex. {‘response_format’: [Some Structure]} )

property info: dict

Return clean information about the LLM Client configuration.

abstract property provider_name: str

Get the provider name

validate() bool

Validate the provided API key by making a call to the provider (sync wrapper).

abstract async validate_async() bool

Validate the provided API key by making a call to the provider (async). Return True if the API key is valid, False if not.