mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
style(spend_tracking): drop inline comments from the failure logging fix
This commit is contained in:
parent
4119cd67a1
commit
21de2b7773
3 changed files with 0 additions and 16 deletions
|
|
@ -131,28 +131,18 @@ class _ProxyDBLogger(CustomLogger):
|
|||
|
||||
existing_litellm_params = request_data.get("litellm_params", {})
|
||||
|
||||
# Routes like /v1/responses, /v1/messages and the batch/file endpoints keep
|
||||
# proxy-internal metadata (model_group, model_info, tags, retries) in
|
||||
# ``litellm_metadata`` so the provider-facing ``metadata`` field stays clean.
|
||||
# Collapse every bucket into one dict, then write it back to all of them so the
|
||||
# bucket ``get_litellm_metadata_from_kwargs`` picks for the spend log carries the
|
||||
# router attribution *and* this failure's status/error information.
|
||||
metadata_key, internal_metadata = get_or_create_metadata_bucket(request_data)
|
||||
merged_metadata = {
|
||||
**(existing_litellm_params.get("metadata") or {}),
|
||||
**(existing_litellm_params.get("litellm_metadata") or {}),
|
||||
**internal_metadata,
|
||||
}
|
||||
# Identity comes from the authenticated key alone; a caller-supplied
|
||||
# user_api_key* field in the request body must never attribute spend.
|
||||
spend_metadata = {key: value for key, value in merged_metadata.items() if not key.startswith("user_api_key")}
|
||||
spend_metadata.update(_metadata)
|
||||
|
||||
request_data["litellm_params"]["proxy_server_request"] = (
|
||||
request_data.get("proxy_server_request") or existing_litellm_params.get("proxy_server_request") or {}
|
||||
)
|
||||
# Failures that never reached the SDK carry no call_type, so the row lands
|
||||
# without one and can't be attributed to the route the caller used.
|
||||
route_call_type = get_primary_call_type_for_route(request_route)
|
||||
if not request_data.get("call_type") and route_call_type is not None:
|
||||
request_data["call_type"] = route_call_type.value
|
||||
|
|
|
|||
|
|
@ -2254,10 +2254,6 @@ class ProxyLogging:
|
|||
)
|
||||
|
||||
input: Union[list, str, dict] = ""
|
||||
# The Logging object above was built from the raw HTTP route, so its call_type
|
||||
# is not a CallTypes value yet. The route is authoritative; the request body
|
||||
# shape is only a fallback for routes outside the mapping (guessing from the
|
||||
# body mislabels e.g. a /v1/responses request with a list input as embeddings).
|
||||
route_call_type = get_primary_call_type_for_route(route)
|
||||
normalized_call_type: str | None = route_call_type.value if route_call_type is not None else None
|
||||
if "messages" in request_data and isinstance(request_data["messages"], list):
|
||||
|
|
|
|||
|
|
@ -2482,8 +2482,6 @@ async def test_post_call_failure_hook_auth_error_llm_api_route():
|
|||
"/v1/embeddings",
|
||||
"aembedding",
|
||||
),
|
||||
# #35068: a Responses request also carries "input"; the route decides the
|
||||
# call type, so it must not be attributed to embeddings
|
||||
(
|
||||
{"model": "bad-model", "input": ["hello"]},
|
||||
"/v1/responses",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue