fix(utils.py): add metadata to logging obj on setup, if exists

This commit is contained in:
Krrish Dholakia 2024-01-19 17:29:47 -08:00
parent 1ec5083542
commit f05aba1f85
2 changed files with 11 additions and 11 deletions

View file

@ -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
@ -5731,15 +5740,6 @@ def exception_type(
model=model,
llm_provider="openai",
)
else:
exception_mapping_worked = True
raise APIError(
status_code=original_exception.status_code,
message=f"OpenAIException - {original_exception.message}",
llm_provider="openai",
model=model,
request=original_exception.request,
)
else:
# if no status code then it is an APIConnectionError: https://github.com/openai/openai-python#handling-errors
raise APIConnectionError(