Default openai llm
DefaultOpenAILLM
¶
Bases: OpenAIStyleLLM
The agentUniverse default openai llm module.
LLM parameters, such as name/description/model_name/max_tokens, are injected into this class by the default_openai_llm.yaml configuration.
Source code in agentuniverse/llm/default/default_openai_llm.py
Python
class DefaultOpenAILLM(OpenAIStyleLLM):
"""The agentUniverse default openai llm module.
LLM parameters, such as name/description/model_name/max_tokens,
are injected into this class by the default_openai_llm.yaml configuration.
"""
api_key: Optional[str] = Field(default_factory=lambda: get_from_env("OPENAI_API_KEY"))
organization: Optional[str] = Field(default_factory=lambda: get_from_env("OPENAI_ORGANIZATION"))
api_base: Optional[str] = Field(default_factory=lambda: get_from_env("OPENAI_API_BASE"))
proxy: Optional[str] = Field(default_factory=lambda: get_from_env("OPENAI_PROXY"))
def call(self, messages: list, **kwargs: Any) -> LLMOutput:
""" The call method of the LLM.
Users can customize how the model interacts by overriding call method of the LLM class.
Args:
messages (list): The messages to send to the LLM.
**kwargs: Arbitrary keyword arguments.
"""
return super().call(messages, **kwargs)
async def acall(self, messages: list, **kwargs: Any) -> LLMOutput:
""" The async call method of the LLM.
Users can customize how the model interacts by overriding acall method of the LLM class.
Args:
messages (list): The messages to send to the LLM.
**kwargs: Arbitrary keyword arguments.
"""
return await super().acall(messages, **kwargs)
def max_context_length(self) -> int:
"""Max context length.
The total length of input tokens and generated tokens is limited by the openai model's context length.
"""
return OPENAI_MAX_CONTEXT_LENGTH.get(self.model_name, 4096)
acall(messages, **kwargs)
async
¶
The async call method of the LLM.
Users can customize how the model interacts by overriding acall method of the LLM class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages |
list
|
The messages to send to the LLM. |
required |
**kwargs |
Any
|
Arbitrary keyword arguments. |
{}
|
Source code in agentuniverse/llm/default/default_openai_llm.py
Python
async def acall(self, messages: list, **kwargs: Any) -> LLMOutput:
""" The async call method of the LLM.
Users can customize how the model interacts by overriding acall method of the LLM class.
Args:
messages (list): The messages to send to the LLM.
**kwargs: Arbitrary keyword arguments.
"""
return await super().acall(messages, **kwargs)
call(messages, **kwargs)
¶
The call method of the LLM.
Users can customize how the model interacts by overriding call method of the LLM class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages |
list
|
The messages to send to the LLM. |
required |
**kwargs |
Any
|
Arbitrary keyword arguments. |
{}
|
Source code in agentuniverse/llm/default/default_openai_llm.py
Python
def call(self, messages: list, **kwargs: Any) -> LLMOutput:
""" The call method of the LLM.
Users can customize how the model interacts by overriding call method of the LLM class.
Args:
messages (list): The messages to send to the LLM.
**kwargs: Arbitrary keyword arguments.
"""
return super().call(messages, **kwargs)
max_context_length()
¶
Max context length.
The total length of input tokens and generated tokens is limited by the openai model's context length.