浏览代码

fix: openai issue

Timothy J. Baek 1 年之前
父节点
当前提交
1e03871748
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      backend/apps/openai/main.py

+ 6 - 2
backend/apps/openai/main.py

@@ -144,7 +144,9 @@ async def speech(request: Request, user=Depends(get_verified_user)):
                 except:
                 except:
                     error_detail = f"External: {e}"
                     error_detail = f"External: {e}"
 
 
-            raise HTTPException(status_code=r.status_code, detail=error_detail)
+            raise HTTPException(
+                status_code=r.status_code if r else 500, detail=error_detail
+            )
 
 
     except ValueError:
     except ValueError:
         raise HTTPException(status_code=401, detail=ERROR_MESSAGES.OPENAI_NOT_FOUND)
         raise HTTPException(status_code=401, detail=ERROR_MESSAGES.OPENAI_NOT_FOUND)
@@ -328,4 +330,6 @@ async def proxy(path: str, request: Request, user=Depends(get_verified_user)):
             except:
             except:
                 error_detail = f"External: {e}"
                 error_detail = f"External: {e}"
 
 
-        raise HTTPException(status_code=r.status_code, detail=error_detail)
+        raise HTTPException(
+            status_code=r.status_code if r else 500, detail=error_detail
+        )