mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
perf(proxy_server.py): remove db logic from _get_config_from_file
was causing db calls to occur on every llm request, if team_id was set on key
This commit is contained in:
parent
9794cfd1af
commit
2d5543c502
3 changed files with 4 additions and 40 deletions
|
|
@ -299,8 +299,6 @@ async def add_litellm_data_to_request( # noqa: PLR0915
|
|||
"""
|
||||
from litellm.proxy.proxy_server import llm_router, premium_user
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
safe_add_api_version_from_query_params(data, request)
|
||||
|
||||
_headers = clean_headers(
|
||||
|
|
@ -479,7 +477,7 @@ async def add_litellm_data_to_request( # noqa: PLR0915
|
|||
### END-USER SPECIFIC PARAMS ###
|
||||
if user_api_key_dict.allowed_model_region is not None:
|
||||
data["allowed_model_region"] = user_api_key_dict.allowed_model_region
|
||||
|
||||
start_time = time.time()
|
||||
## [Enterprise Only]
|
||||
# Add User-IP Address
|
||||
requester_ip_address = ""
|
||||
|
|
|
|||
|
|
@ -1373,9 +1373,6 @@ class ProxyConfig:
|
|||
) -> dict:
|
||||
"""
|
||||
Given a config file path, load the config from the file.
|
||||
|
||||
If `store_model_in_db` is True, then read the DB and update the config with the DB values.
|
||||
|
||||
Args:
|
||||
config_file_path (str): path to the config file
|
||||
Returns:
|
||||
|
|
@ -1401,40 +1398,6 @@ class ProxyConfig:
|
|||
"litellm_settings": {},
|
||||
}
|
||||
|
||||
## DB
|
||||
if prisma_client is not None and (
|
||||
general_settings.get("store_model_in_db", False) is True
|
||||
or store_model_in_db is True
|
||||
):
|
||||
_tasks = []
|
||||
keys = [
|
||||
"general_settings",
|
||||
"router_settings",
|
||||
"litellm_settings",
|
||||
"environment_variables",
|
||||
]
|
||||
for k in keys:
|
||||
response = prisma_client.get_generic_data(
|
||||
key="param_name", value=k, table_name="config"
|
||||
)
|
||||
_tasks.append(response)
|
||||
|
||||
responses = await asyncio.gather(*_tasks)
|
||||
for response in responses:
|
||||
if response is not None:
|
||||
param_name = getattr(response, "param_name", None)
|
||||
param_value = getattr(response, "param_value", None)
|
||||
if param_name is not None and param_value is not None:
|
||||
# check if param_name is already in the config
|
||||
if param_name in config:
|
||||
if isinstance(config[param_name], dict):
|
||||
config[param_name].update(param_value)
|
||||
else:
|
||||
config[param_name] = param_value
|
||||
else:
|
||||
# if it's not in the config - then add it
|
||||
config[param_name] = param_value
|
||||
|
||||
return config
|
||||
|
||||
async def save_config(self, new_config: dict):
|
||||
|
|
@ -1500,8 +1463,10 @@ class ProxyConfig:
|
|||
- for a given team id
|
||||
- return the relevant completion() call params
|
||||
"""
|
||||
|
||||
# load existing config
|
||||
config = await self.get_config()
|
||||
|
||||
## LITELLM MODULE SETTINGS (e.g. litellm.drop_params=True,..)
|
||||
litellm_settings = config.get("litellm_settings", {})
|
||||
all_teams_config = litellm_settings.get("default_team_settings", None)
|
||||
|
|
|
|||
|
|
@ -1400,6 +1400,7 @@ class PrismaClient:
|
|||
|
||||
return
|
||||
|
||||
@log_to_opentelemetry
|
||||
@backoff.on_exception(
|
||||
backoff.expo,
|
||||
Exception, # base exception to catch for the backoff
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue