diff --git a/proxy/routes/proxy.py b/proxy/routes/proxy.py index b401dba..dddbce3 100644 --- a/proxy/routes/proxy.py +++ b/proxy/routes/proxy.py @@ -25,7 +25,7 @@ proxy = APIRouter() MISSING_INVARIANT_AUTH_HEADER = "Missing invariant-authorization header" MISSING_AUTH_HEADER = "Missing authorization header" NOT_SUPPORTED_ENDPOINT = "Not supported OpenAI endpoint" -FAILED_TO_PUSH_TRACE = "Failed to push trace to the dataset" +FAILED_TO_PUSH_TRACE = "Failed to push trace to the dataset: " def validate_headers( @@ -76,11 +76,13 @@ async def openai_proxy( ] _ = push_trace( dataset_name=dataset_name, - messages=messages, + messages=[messages], invariant_authorization=request.headers.get("invariant-authorization"), ) except Exception as e: - raise HTTPException(status_code=500, detail=FAILED_TO_PUSH_TRACE) from e + raise HTTPException( + status_code=500, detail=FAILED_TO_PUSH_TRACE + str(e) + ) from e # Detect if original request expects gzip encoding if "gzip" in request.headers.get("accept-encoding", "").lower(): @@ -91,6 +93,8 @@ async def openai_proxy( compressed_response = gzip_buffer.getvalue() response_headers = dict(response.headers) + response_headers.pop("Content-Encoding", None) + response_headers.pop("Content-Length", None) response_headers["Content-Encoding"] = "gzip" response_headers["Content-Length"] = str(len(compressed_response)) diff --git a/proxy/utils/explorer.py b/proxy/utils/explorer.py index fd275f1..252406d 100644 --- a/proxy/utils/explorer.py +++ b/proxy/utils/explorer.py @@ -33,6 +33,4 @@ def push_trace( ) return {"trace_id": push_trace_response.id[0]} except Exception as e: - raise HTTPException( - status_code=500, detail="Failed to push traces to the dataset" - ) from e + raise HTTPException(status_code=500, detail=str(e)) from e