forked from phoenix/litellm-mirror
fix check for streaming response
This commit is contained in:
parent
9f916636e1
commit
acf350a2fb
1 changed files with 10 additions and 4 deletions
|
@ -478,10 +478,9 @@ async def pass_through_request( # noqa: PLR0915
|
||||||
json=_parsed_body,
|
json=_parsed_body,
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
verbose_proxy_logger.debug("response.headers= %s", response.headers)
|
||||||
response.headers.get("content-type") is not None
|
|
||||||
and response.headers["content-type"] == "text/event-stream"
|
if _is_streaming_response(response) is True:
|
||||||
):
|
|
||||||
try:
|
try:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except httpx.HTTPStatusError as e:
|
except httpx.HTTPStatusError as e:
|
||||||
|
@ -621,6 +620,13 @@ def create_pass_through_route(
|
||||||
return endpoint_func
|
return endpoint_func
|
||||||
|
|
||||||
|
|
||||||
|
def _is_streaming_response(response: httpx.Response) -> bool:
|
||||||
|
_content_type = response.headers.get("content-type")
|
||||||
|
if _content_type is not None and "text/event-stream" in _content_type:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
async def initialize_pass_through_endpoints(pass_through_endpoints: list):
|
async def initialize_pass_through_endpoints(pass_through_endpoints: list):
|
||||||
|
|
||||||
verbose_proxy_logger.debug("initializing pass through endpoints")
|
verbose_proxy_logger.debug("initializing pass through endpoints")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue