fix - log api_base in errors

This commit is contained in:
Ishaan Jaff 2024-04-30 13:02:42 -07:00
parent 06804bc70a
commit ee2a2ce559
3 changed files with 7 additions and 0 deletions

View file

@ -914,6 +914,7 @@ class LiteLLM_SpendLogs(LiteLLMBase):
class LiteLLM_ErrorLogs(LiteLLMBase): class LiteLLM_ErrorLogs(LiteLLMBase):
request_id: Optional[str] = str(uuid.uuid4()) request_id: Optional[str] = str(uuid.uuid4())
api_base: Optional[str] = ""
model_name: Optional[str] = "" model_name: Optional[str] = ""
model_id: Optional[str] = "" model_id: Optional[str] = ""
request_kwargs: Optional[Json] = {} request_kwargs: Optional[Json] = {}

View file

@ -1239,6 +1239,9 @@ async def _PROXY_failure_handler(
_litellm_params = kwargs.get("litellm_params", {}) or {} _litellm_params = kwargs.get("litellm_params", {}) or {}
_metadata = _litellm_params.get("metadata", {}) or {} _metadata = _litellm_params.get("metadata", {}) or {}
_model_id = _metadata.get("model_info", {}).get("id", None) _model_id = _metadata.get("model_info", {}).get("id", None)
api_base = litellm.get_api_base(model=_model, optional_params=_litellm_params)
verbose_proxy_logger.debug( verbose_proxy_logger.debug(
"\nexception_type", "\nexception_type",
_exception_type, _exception_type,
@ -1252,8 +1255,10 @@ async def _PROXY_failure_handler(
traceback, traceback,
) )
error_log = LiteLLM_ErrorLogs( error_log = LiteLLM_ErrorLogs(
request_id=str(uuid.uuid4()),
model_name=_model, model_name=_model,
model_id=_model_id, model_id=_model_id,
api_base=api_base,
exception_type=_exception_type, exception_type=_exception_type,
status_code=_status_code, status_code=_status_code,
exception_string=str(_exception), exception_string=str(_exception),

View file

@ -186,6 +186,7 @@ model LiteLLM_SpendLogs {
// View spend, model, api_key per request // View spend, model, api_key per request
model LiteLLM_ErrorLogs { model LiteLLM_ErrorLogs {
request_id String @id @default(uuid()) request_id String @id @default(uuid())
api_base String @default("")
model_name String @default("") // public model_name / model_group model_name String @default("") // public model_name / model_group
model_id String @default("") // ID of model in ProxyModelTable model_id String @default("") // ID of model in ProxyModelTable
request_kwargs Json @default("{}") request_kwargs Json @default("{}")