From 211eb8de1640a6a28a2d5e43163e4b14d8563c69 Mon Sep 17 00:00:00 2001 From: Anton Dubovik Date: Tue, 19 Nov 2024 10:54:07 +0000 Subject: [PATCH] fix: removed content-encoding header to avoid decoding errors (#174) --- aidial_adapter_openai/app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aidial_adapter_openai/app.py b/aidial_adapter_openai/app.py index 3288425..11ce937 100644 --- a/aidial_adapter_openai/app.py +++ b/aidial_adapter_openai/app.py @@ -215,10 +215,16 @@ async def embedding(deployment_id: str, request: Request): def openai_exception_handler(request: Request, e: DialException): if isinstance(e, APIStatusError): r = e.response + headers = r.headers + + # Avoid encoding the error message when the original response was encoded. + if "Content-Encoding" in headers: + del headers["Content-Encoding"] + return Response( content=r.content, status_code=r.status_code, - headers=r.headers, + headers=headers, ) if isinstance(e, APITimeoutError):