Skip to content
Night Brownie Night Brownie

Base

Abstract LLMBackend base class and factory.

Classes:

  • LLMBackend

    Abstract base class for LLM provider backends.

Functions:

  • from_config

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

LLMBackend

Bases: ABC

Abstract base class for LLM provider backends.

All concrete backends must implement [complete][.].

Methods:

  • complete

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

complete abstractmethod

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

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

Parameters:

  • prompt (str) –

    The user prompt to send to the model.

  • system (str | None, default: None ) –

    Optional system prompt to configure model behaviour.

Returns:

  • str

    The model's text response as a string.

from_config

from_config(config: LLMConfig) -> LLMBackend

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

Parameters:

  • config (LLMConfig) –

    The LLM section of the Night Brownie runtime config.

Returns:

  • LLMBackend

    A concrete [LLMBackend][] instance.

Raises:

  • ValueError

    If config.provider is not a supported backend.