MCPcopy Create free account
hub / github.com/BerriAI/litellm / _handle_logging_proxy_only_error

Method _handle_logging_proxy_only_error

litellm/proxy/utils.py:2134–2233  ·  view source on GitHub ↗

Handle logging for proxy only errors by calling `litellm_logging_obj.async_failure_handler` Is triggered when self._is_proxy_only_error() returns True

(
        self,
        request_data: dict,
        user_api_key_dict: UserAPIKeyAuth,
        route: Optional[str] = None,
        original_exception: Optional[Exception] = None,
    )

Source from the content-addressed store, hash-verified

2132 )
2133
2134 async def _handle_logging_proxy_only_error(
2135 self,
2136 request_data: dict,
2137 user_api_key_dict: UserAPIKeyAuth,
2138 route: Optional[str] = None,
2139 original_exception: Optional[Exception] = None,
2140 ):
2141 """
2142 Handle logging for proxy only errors by calling `litellm_logging_obj.async_failure_handler`
2143
2144 Is triggered when self._is_proxy_only_error() returns True
2145 """
2146 litellm_logging_obj: Optional[Logging] = request_data.get("litellm_logging_obj", None)
2147 if litellm_logging_obj is None:
2148 from litellm._uuid import uuid
2149
2150 request_data["litellm_call_id"] = str(uuid.uuid4())
2151 user_api_key_logged_metadata = LiteLLMProxyRequestSetup.get_sanitized_user_information_from_key(
2152 user_api_key_dict=user_api_key_dict
2153 )
2154
2155 litellm_logging_obj, data = litellm.utils.function_setup(
2156 original_function=route or "IGNORE_THIS",
2157 rules_obj=litellm.utils.Rules(),
2158 start_time=datetime.now(),
2159 **request_data,
2160 )
2161 if "metadata" not in request_data:
2162 request_data["metadata"] = {}
2163 request_data["metadata"].update(user_api_key_logged_metadata)
2164
2165 if litellm_logging_obj is not None:
2166 ## UPDATE LOGGING INPUT
2167 _optional_params = {}
2168 _litellm_params = {}
2169
2170 litellm_param_keys = LoggedLiteLLMParams.__annotations__.keys()
2171 for k, v in request_data.items():
2172 if k in litellm_param_keys:
2173 _litellm_params[k] = v
2174 elif k not in ("model", "user", "litellm_logging_obj"):
2175 _optional_params[k] = v
2176
2177 litellm_logging_obj.update_environment_variables(
2178 model=request_data.get("model", ""),
2179 user=request_data.get("user", ""),
2180 optional_params=_optional_params,
2181 litellm_params=_litellm_params,
2182 )
2183
2184 input: Union[list, str, dict] = ""
2185 normalized_call_type: Optional[str] = None
2186 if "messages" in request_data and isinstance(request_data["messages"], list):
2187 input = request_data["messages"]
2188 litellm_logging_obj.model_call_details["messages"] = input
2189 if litellm_logging_obj.call_type != CallTypes.pass_through.value:
2190 normalized_call_type = CallTypes.acompletion.value
2191 elif "prompt" in request_data and isinstance(request_data["prompt"], str):

Calls 10

getMethod · 0.65
nowMethod · 0.45
updateMethod · 0.45
keysMethod · 0.45
itemsMethod · 0.45
pre_callMethod · 0.45
async_failure_handlerMethod · 0.45
startMethod · 0.45