fix(proxy): remove per-chunk debug log and use _usage_stripped flag

- Remove verbose_proxy_logger.debug that formatted every streaming chunk
- Honor _usage_stripped flag from streaming handler to exclude usage
  during model_dump_json serialization instead of reconstructing objects
This commit is contained in:
Ishaan Jaffer 2026-02-18 12:33:15 -08:00
parent f172a34f90
commit 8140f6caf2

View file

@ -5074,10 +5074,6 @@ async def async_data_generator(
response=response,
request_data=request_data,
):
verbose_proxy_logger.debug(
"async_data_generator: received streaming chunk - {}".format(chunk)
)
### CALL HOOKS ### - modify outgoing data
chunk = await proxy_logging_obj.async_post_call_streaming_hook(
user_api_key_dict=user_api_key_dict,
@ -5098,7 +5094,14 @@ async def async_data_generator(
)
if isinstance(chunk, BaseModel):
chunk = chunk.model_dump_json(exclude_none=True, exclude_unset=True)
if getattr(chunk, "_usage_stripped", False):
chunk = chunk.model_dump_json(
exclude_none=True, exclude_unset=True, exclude={"usage"} # type: ignore
)
else:
chunk = chunk.model_dump_json(
exclude_none=True, exclude_unset=True
)
elif isinstance(chunk, str) and chunk.startswith("data: "):
error_message = chunk
break