OpenAILLMClient
dbally.llm_client.openai_client.OpenAIClient
Bases: LLMClient
OpenAIClient
is a class designed to interact with OpenAI's language model (LLM) endpoints,
particularly for the GPT models.
PARAMETER | DESCRIPTION |
---|---|
model_name |
Name of the OpenAI's model to be used, default is "gpt-3.5-turbo".
TYPE:
|
api_key |
OpenAI's API key. If None OPENAI_API_KEY environment variable will be used
TYPE:
|
Source code in src/dbally/llm_client/openai_client.py
text_generation
async
text_generation(template: PromptTemplate, fmt: dict, *, event_tracker: Optional[EventTracker] = None, frequency_penalty: Optional[float] = 0.0, max_tokens: Optional[int] = 128, n: Optional[int] = 1, presence_penalty: Optional[float] = 0.0, seed: Optional[int] = None, stop: Optional[Union[str, List[str]]] = None, temperature: Optional[float] = 1.0, top_p: Optional[float] = 1.0) -> str
For a given a PromptType and format dict creates a prompt and returns the response from LLM.
RETURNS | DESCRIPTION |
---|---|
str
|
Text response from LLM. |
Source code in src/dbally/llm_client/base.py
call
async
call(prompt: Union[str, ChatFormat], response_format: Optional[Dict[str, str]], options: LLMOptions, event: LLMEvent) -> str
Calls the OpenAI API endpoint.
PARAMETER | DESCRIPTION |
---|---|
prompt |
Prompt as an OpenAI client style list.
TYPE:
|
response_format |
Optional argument used in the OpenAI API - used to force the json output
TYPE:
|
options |
Additional settings used by the LLM.
TYPE:
|
event |
container with the prompt, LLM response and call metrics.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
Response string from LLM. |