mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
Merge pull request #1531 from BerriAI/litellm_max_parallel_request_invalid_provider_fix
fix(utils.py): add metadata to logging obj on setup, if exists (fixes max parallel request bug)
This commit is contained in:
commit
749f0b7602
3 changed files with 21 additions and 4 deletions
|
|
@ -186,4 +186,4 @@ class MaxParallelRequestsHandler(CustomLogger):
|
|||
request_count_api_key, new_val, ttl=60
|
||||
) # save in cache for up to 1 min.
|
||||
except Exception as e:
|
||||
self.print_verbose(f"An exception occurred - {str(e)}") # noqa
|
||||
print(f"An exception occurred - {str(e)}") # noqa
|
||||
|
|
|
|||
|
|
@ -2227,7 +2227,11 @@ async def info_key_fn(
|
|||
)
|
||||
key_info = await prisma_client.get_data(token=key)
|
||||
## REMOVE HASHED TOKEN INFO BEFORE RETURNING ##
|
||||
key_info = key_info.model_dump()
|
||||
try:
|
||||
key_info = key_info.model_dump() # noqa
|
||||
except:
|
||||
# if using pydantic v1
|
||||
key_info = key_info.dict()
|
||||
key_info.pop("token")
|
||||
return {"key": key, "info": key_info}
|
||||
except Exception as e:
|
||||
|
|
@ -2366,7 +2370,11 @@ async def user_info(
|
|||
)
|
||||
## REMOVE HASHED TOKEN INFO before returning ##
|
||||
for key in keys:
|
||||
key = key.model_dump()
|
||||
try:
|
||||
key = key.model_dump() # noqa
|
||||
except:
|
||||
# if using pydantic v1
|
||||
key = key.dict()
|
||||
key.pop("token", None)
|
||||
return {"user_id": user_id, "user_info": user_info, "keys": keys}
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ class Logging:
|
|||
self.model = model
|
||||
self.user = user
|
||||
self.litellm_params = litellm_params
|
||||
self.logger_fn = litellm_params["logger_fn"]
|
||||
self.logger_fn = litellm_params.get("logger_fn", None)
|
||||
print_verbose(f"self.optional_params: {self.optional_params}")
|
||||
self.model_call_details = {
|
||||
"model": self.model,
|
||||
|
|
@ -1941,6 +1941,15 @@ def client(original_function):
|
|||
call_type=call_type,
|
||||
start_time=start_time,
|
||||
)
|
||||
## check if metadata is passed in
|
||||
if "metadata" in kwargs:
|
||||
litellm_params = {"metadata": kwargs["metadata"]}
|
||||
logging_obj.update_environment_variables(
|
||||
model=model,
|
||||
user="",
|
||||
optional_params={},
|
||||
litellm_params=litellm_params,
|
||||
)
|
||||
return logging_obj
|
||||
except Exception as e:
|
||||
import logging
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue