forked from phoenix/litellm-mirror
fix(proxy_server.py): drop none values in streaming response
This commit is contained in:
parent
05e096ce25
commit
57998c28dc
2 changed files with 15 additions and 11 deletions
|
@ -2115,10 +2115,9 @@ async def async_data_generator(response, user_api_key_dict):
|
|||
try:
|
||||
start_time = time.time()
|
||||
async for chunk in response:
|
||||
verbose_proxy_logger.debug(f"returned chunk: {chunk}")
|
||||
assert isinstance(chunk, litellm.ModelResponse)
|
||||
chunk = chunk.model_dump_json(exclude_none=True)
|
||||
try:
|
||||
yield f"data: {json.dumps(chunk.model_dump(exclude_none=True))}\n\n"
|
||||
yield f"data: {chunk}\n\n"
|
||||
except Exception as e:
|
||||
yield f"data: {str(e)}\n\n"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue