Skip to content

Commit

Permalink
fix: removed content-encoding header to avoid decoding errors (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik authored Nov 19, 2024
1 parent 837a7a0 commit 211eb8d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion aidial_adapter_openai/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 211eb8d

Please sign in to comment.