ghostdrive1 commited on
Commit
aa9a63b
·
verified ·
1 Parent(s): c2c9236

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. main.py +13 -1
main.py CHANGED
@@ -76,7 +76,19 @@ async def chat_endpoint(request: ChatRequest):
76
  return {"response": reply, "doc": True}
77
 
78
  except httpx.HTTPStatusError as e:
79
- raise HTTPException(status_code=e.response.status_code, detail=f"Provider error: {e.response.text}")
 
 
 
 
 
 
 
 
 
 
 
 
80
  except Exception as e:
81
  raise HTTPException(status_code=500, detail=str(e))
82
 
 
76
  return {"response": reply, "doc": True}
77
 
78
  except httpx.HTTPStatusError as e:
79
+ status = e.response.status_code
80
+ if status == 401:
81
+ detail = (
82
+ f"401 Unauthorized from {request.provider}. "
83
+ f"Check that your API key is valid for {request.provider} "
84
+ f"and that the model '{request.model}' is available on {request.provider}. "
85
+ f"Tip: Make sure the model you selected belongs to the same provider as your API key."
86
+ )
87
+ elif status == 404:
88
+ detail = f"404: Model '{request.model}' not found on {request.provider}. Select a model from the correct provider tab."
89
+ else:
90
+ detail = f"Provider error {status}: {e.response.text[:300]}"
91
+ raise HTTPException(status_code=status, detail=detail)
92
  except Exception as e:
93
  raise HTTPException(status_code=500, detail=str(e))
94