fix(proxy_server.py): don't return None objects

This commit is contained in:
Krrish Dholakia 2024-02-27 13:51:54 -08:00
parent b63beaead0
commit fa53a47951

View file

@ -2116,8 +2116,9 @@ async def async_data_generator(response, user_api_key_dict):
start_time = time.time() start_time = time.time()
async for chunk in response: async for chunk in response:
verbose_proxy_logger.debug(f"returned chunk: {chunk}") verbose_proxy_logger.debug(f"returned chunk: {chunk}")
assert isinstance(chunk, litellm.ModelResponse)
try: try:
yield f"data: {json.dumps(chunk.dict())}\n\n" yield f"data: {json.dumps(chunk.model_dump(exclude_none=True))}\n\n"
except Exception as e: except Exception as e:
yield f"data: {str(e)}\n\n" yield f"data: {str(e)}\n\n"