fix(proxy_server.py): fix returning response headers on exception
This commit is contained in:
parent
fde434be66
commit
de8230ed41
@ -329,6 +329,7 @@ class UserAPIKeyCacheTTLEnum(enum.Enum):
|
||||
@app.exception_handler(ProxyException)
|
||||
async def openai_exception_handler(request: Request, exc: ProxyException):
|
||||
# NOTE: DO NOT MODIFY THIS, its crucial to map to Openai exceptions
|
||||
headers = exc.headers
|
||||
return JSONResponse(
|
||||
status_code=(
|
||||
int(exc.code) if exc.code else status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||
@ -341,6 +342,7 @@ async def openai_exception_handler(request: Request, exc: ProxyException):
|
||||
"code": exc.code,
|
||||
}
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
|
||||
@ -2710,16 +2712,6 @@ def model_list(
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(ProxyException)
|
||||
async def proxy_exception_handler(request: Request, exc: ProxyException):
|
||||
headers = exc.headers
|
||||
return JSONResponse(
|
||||
status_code=exc.code or 400,
|
||||
content=exc.to_dict(),
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/v1/chat/completions",
|
||||
dependencies=[Depends(user_api_key_auth)],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user