Spaces:
Paused
Paused
Update api/utils.py
Browse files- api/utils.py +3 -3
api/utils.py
CHANGED
|
@@ -39,7 +39,7 @@ def create_chat_completion_data(
|
|
| 39 |
|
| 40 |
def verify_app_secret(credentials: HTTPAuthorizationCredentials = Depends(security)):
|
| 41 |
if credentials.credentials != APP_SECRET:
|
| 42 |
-
raise HTTPException(
|
| 43 |
return credentials.credentials
|
| 44 |
|
| 45 |
|
|
@@ -123,10 +123,10 @@ async def process_streaming_response(request: ChatRequest):
|
|
| 123 |
yield "data: [DONE]\n\n"
|
| 124 |
except httpx.HTTPStatusError as e:
|
| 125 |
logger.error(f"HTTP error occurred: {e}")
|
| 126 |
-
raise HTTPException(
|
| 127 |
except httpx.RequestError as e:
|
| 128 |
logger.error(f"Error occurred during request: {e}")
|
| 129 |
-
raise HTTPException(
|
| 130 |
|
| 131 |
|
| 132 |
async def process_non_streaming_response(request: ChatRequest):
|
|
|
|
| 39 |
|
| 40 |
def verify_app_secret(credentials: HTTPAuthorizationCredentials = Depends(security)):
|
| 41 |
if credentials.credentials != APP_SECRET:
|
| 42 |
+
raise HTTPException(403, "Invalid APP_SECRET")
|
| 43 |
return credentials.credentials
|
| 44 |
|
| 45 |
|
|
|
|
| 123 |
yield "data: [DONE]\n\n"
|
| 124 |
except httpx.HTTPStatusError as e:
|
| 125 |
logger.error(f"HTTP error occurred: {e}")
|
| 126 |
+
raise HTTPException(e.response.status_code, str(e))
|
| 127 |
except httpx.RequestError as e:
|
| 128 |
logger.error(f"Error occurred during request: {e}")
|
| 129 |
+
raise HTTPException(500, str(e))
|
| 130 |
|
| 131 |
|
| 132 |
async def process_non_streaming_response(request: ChatRequest):
|