forked from phoenix/litellm-mirror
(feat) proxy set default_key_generate_params
This commit is contained in:
parent
d2de7ba4fe
commit
72b9e539c8
2 changed files with 24 additions and 0 deletions
|
@ -143,6 +143,7 @@ model_cost_map_url: str = "https://raw.githubusercontent.com/BerriAI/litellm/mai
|
||||||
suppress_debug_info = False
|
suppress_debug_info = False
|
||||||
dynamodb_table_name: Optional[str] = None
|
dynamodb_table_name: Optional[str] = None
|
||||||
s3_callback_params: Optional[Dict] = None
|
s3_callback_params: Optional[Dict] = None
|
||||||
|
default_key_generate_params: Optional[Dict] = None
|
||||||
#### RELIABILITY ####
|
#### RELIABILITY ####
|
||||||
request_timeout: Optional[float] = 6000
|
request_timeout: Optional[float] = 6000
|
||||||
num_retries: Optional[int] = None # per model endpoint
|
num_retries: Optional[int] = None # per model endpoint
|
||||||
|
|
|
@ -1117,6 +1117,9 @@ class ProxyConfig:
|
||||||
# see usage here: https://docs.litellm.ai/docs/proxy/caching
|
# see usage here: https://docs.litellm.ai/docs/proxy/caching
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
verbose_proxy_logger.debug(
|
||||||
|
f"{blue_color_code} setting litellm.{key}={value}{reset_color_code}"
|
||||||
|
)
|
||||||
setattr(litellm, key, value)
|
setattr(litellm, key, value)
|
||||||
|
|
||||||
## GENERAL SERVER SETTINGS (e.g. master key,..) # do this after initializing litellm, to ensure sentry logging works for proxylogging
|
## GENERAL SERVER SETTINGS (e.g. master key,..) # do this after initializing litellm, to ensure sentry logging works for proxylogging
|
||||||
|
@ -2385,6 +2388,26 @@ async def generate_key_fn(
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_403_FORBIDDEN, detail=message
|
status_code=status.HTTP_403_FORBIDDEN, detail=message
|
||||||
)
|
)
|
||||||
|
# check if user set default key/generate params on config.yaml
|
||||||
|
if litellm.default_key_generate_params is not None:
|
||||||
|
for elem in data:
|
||||||
|
key, value = elem
|
||||||
|
if value is None and key in [
|
||||||
|
"max_budget",
|
||||||
|
"user_id",
|
||||||
|
"team_id",
|
||||||
|
"max_parallel_requests",
|
||||||
|
"tpm_limit",
|
||||||
|
"rpm_limit",
|
||||||
|
"budget_duration",
|
||||||
|
]:
|
||||||
|
setattr(
|
||||||
|
data, key, litellm.default_key_generate_params.get(key, None)
|
||||||
|
)
|
||||||
|
elif key == "models" and value == []:
|
||||||
|
setattr(data, key, litellm.default_key_generate_params.get(key, []))
|
||||||
|
elif key == "metadata" and value == {}:
|
||||||
|
setattr(data, key, litellm.default_key_generate_params.get(key, {}))
|
||||||
|
|
||||||
data_json = data.json() # type: ignore
|
data_json = data.json() # type: ignore
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue