feat(proxy_server.py): handle pydantic mockselvar error

Fixes https://github.com/BerriAI/litellm/issues/4898#issuecomment-2252105485
This commit is contained in:
Krrish Dholakia 2024-07-26 08:38:08 -07:00
parent 35737d04d3
commit 1d6c39a607
2 changed files with 68 additions and 2 deletions

View file

@ -2371,13 +2371,15 @@ async def async_data_generator(
try:
start_time = time.time()
async for chunk in response:
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, response=chunk
)
chunk = chunk.model_dump_json(exclude_none=True)
chunk = chunk.model_dump_json(exclude_none=True, exclude_unset=True)
try:
yield f"data: {chunk}\n\n"
except Exception as e: