mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix logic for intializing openai clients
This commit is contained in:
parent
0601768bb8
commit
a0c5fb81b8
4 changed files with 40 additions and 26 deletions
|
@ -8,6 +8,7 @@ from typing import Any, Dict, List, Optional, Union
|
|||
import httpx
|
||||
import openai
|
||||
|
||||
import litellm
|
||||
from litellm.llms.base_llm.chat.transformation import BaseLLMException
|
||||
|
||||
|
||||
|
@ -92,3 +93,31 @@ def drop_params_from_unprocessable_entity_error(
|
|||
new_data = {k: v for k, v in data.items() if k not in invalid_params}
|
||||
|
||||
return new_data
|
||||
|
||||
|
||||
class BaseOpenAILLM:
|
||||
"""
|
||||
Base class for OpenAI LLMs for getting their httpx clients and SSL verification settings
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def _get_async_http_client() -> Optional[httpx.AsyncClient]:
|
||||
if litellm.ssl_verify:
|
||||
return httpx.AsyncClient(
|
||||
limits=httpx.Limits(
|
||||
max_connections=1000, max_keepalive_connections=100
|
||||
),
|
||||
verify=litellm.ssl_verify,
|
||||
)
|
||||
return litellm.aclient_session
|
||||
|
||||
@staticmethod
|
||||
def _get_sync_http_client() -> Optional[httpx.Client]:
|
||||
if litellm.ssl_verify:
|
||||
return httpx.Client(
|
||||
limits=httpx.Limits(
|
||||
max_connections=1000, max_keepalive_connections=100
|
||||
),
|
||||
verify=litellm.ssl_verify,
|
||||
)
|
||||
return litellm.client_session
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue