remove more nesting

This commit is contained in:
Michael Poluektov 2024-08-19 10:34:44 +01:00
parent 32874a816d
commit ce7a1a73ac

View File

@ -680,7 +680,9 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
]
response = await call_next(request)
if isinstance(response, StreamingResponse):
if not isinstance(response, StreamingResponse):
return response
content_type = response.headers["Content-Type"]
is_openai = "text/event-stream" in content_type
is_ollama = "application/x-ndjson" in content_type
@ -699,8 +701,6 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
return StreamingResponse(stream_wrapper(response.body_iterator, data_items))
return response
async def _receive(self, body: bytes):
return {"type": "http.request", "body": body, "more_body": False}