gnilets commited on
Commit
1e6c6ea
·
verified ·
1 Parent(s): e20e67a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -143,9 +143,11 @@ async def proxy_openai_api(request: Request):
143
  headers_to_forward = {k: v for k, v in headers.items() if k.lower() not in {'content-length', 'content-encoding', 'alt-svc'}}
144
 
145
  async def combined_generator():
146
- yield first_chunk
 
147
  async for chunk in response_generator:
148
- yield chunk
 
149
 
150
  return OverrideStreamResponse(combined_generator(), headers=headers_to_forward)
151
  except StopAsyncIteration:
 
143
  headers_to_forward = {k: v for k, v in headers.items() if k.lower() not in {'content-length', 'content-encoding', 'alt-svc'}}
144
 
145
  async def combined_generator():
146
+ if first_chunk.strip():
147
+ yield first_chunk.strip()
148
  async for chunk in response_generator:
149
+ if chunk.strip():
150
+ yield chunk.strip()
151
 
152
  return OverrideStreamResponse(combined_generator(), headers=headers_to_forward)
153
  except StopAsyncIteration: