Skip to content

Base

Abstract LLMBackend base class and factory.

CLASS DESCRIPTION
LLMBackend

Abstract base class for LLM provider backends.

FUNCTION DESCRIPTION
from_config

Instantiate the correct [LLMBackend][] from an [LLMConfig][].

Classes

LLMBackend

Bases: ABC

Abstract base class for LLM provider backends.

All concrete backends must implement complete.

METHOD DESCRIPTION
complete

Send a prompt to the LLM and return the text response.

Functions

complete abstractmethod
complete(prompt: str, system: str | None = None) -> str

Send a prompt to the LLM and return the text response.

PARAMETER DESCRIPTION
prompt

The user prompt to send to the model.

TYPE: str

system

Optional system prompt to configure model behaviour.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
str

The model's text response as a string.

Functions

from_config

from_config(config: LLMConfig) -> LLMBackend

Instantiate the correct LLMBackend from an LLMConfig.

PARAMETER DESCRIPTION
config

The LLM section of the Foreman runtime config.

TYPE: LLMConfig

RETURNS DESCRIPTION
LLMBackend

A concrete LLMBackend instance.

RAISES DESCRIPTION
ValueError

If config.provider is not a supported backend.