llm_openai_api#

class baf.nlp.llm.llm_openai_api.LLMOpenAI(agent, name, parameters, num_previous_messages=1, global_context=None)[source]#

Bases: LLMOpenAICompatible

An LLM wrapper for OpenAI’s models through the OpenAI API.

Inherits all prediction logic from LLMOpenAICompatible. The OpenAI client is initialised with the nlp.openai.api_key config property and the standard https://api.openai.com base URL.

Parameters:
  • agent (Agent) – the agent the LLM belongs to

  • name (str) – the model identifier (e.g. "gpt-4o-mini")

  • parameters (dict) – parameters forwarded to chat.completions.create (e.g. {"temperature": 0.7}).

  • num_previous_messages (int) – number of previous turns to include in chat() calls (must be > 0).

  • global_context (str) – system-level context injected into every request.

client#

the OpenAI client, instantiated in initialize().

Type:

OpenAI

num_previous_messages#

number of previous messages used in chat().

Type:

int

API_KEY_PROPERTY = <baf.core.property.Property object>#

Property constant used to look up the API key from the agent config file.

DEFAULT_BASE_URL = None#

Provider base URL. None → use the OpenAI SDK default (api.openai.com).

_abc_impl = <_abc._abc_data object>#