llm_openai_api#
- class baf.nlp.llm.llm_openai_api.LLMOpenAI(agent, name, parameters, num_previous_messages=1, global_context=None)[source]#
Bases:
LLMOpenAICompatibleAn LLM wrapper for OpenAI’s models through the OpenAI API.
Inherits all prediction logic from
LLMOpenAICompatible. The OpenAI client is initialised with thenlp.openai.api_keyconfig property and the standardhttps://api.openai.combase 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
- 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>#