mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
get_openai_client_cache_key
This commit is contained in:
parent
40418c7bd8
commit
65083ca8da
4 changed files with 199 additions and 10 deletions
|
@ -346,7 +346,7 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):
|
|||
max_retries: Optional[int] = DEFAULT_MAX_RETRIES,
|
||||
organization: Optional[str] = None,
|
||||
client: Optional[Union[OpenAI, AsyncOpenAI]] = None,
|
||||
):
|
||||
) -> Optional[Union[OpenAI, AsyncOpenAI]]:
|
||||
client_initialization_params: Dict = locals()
|
||||
if client is None:
|
||||
if not isinstance(max_retries, int):
|
||||
|
@ -360,8 +360,12 @@ class OpenAIChatCompletion(BaseLLM, BaseOpenAILLM):
|
|||
client_initialization_params=client_initialization_params,
|
||||
client_type="openai",
|
||||
)
|
||||
|
||||
if cached_client:
|
||||
return cached_client
|
||||
if isinstance(cached_client, OpenAI) or isinstance(
|
||||
cached_client, AsyncOpenAI
|
||||
):
|
||||
return cached_client
|
||||
if is_async:
|
||||
_new_client: Union[OpenAI, AsyncOpenAI] = AsyncOpenAI(
|
||||
api_key=api_key,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue