Niansuh commited on
Commit
65d2efc
·
verified ·
1 Parent(s): caad10a

Update api/utils.py

Browse files
Files changed (1) hide show
  1. api/utils.py +3 -2
api/utils.py CHANGED
@@ -6,7 +6,8 @@ import random
6
  import string
7
  from typing import Any, Dict, Optional
8
  import os
9
- from fastapi import HTTPException, Request
 
10
  from dotenv import load_dotenv
11
 
12
  import httpx
@@ -60,7 +61,7 @@ def check_rate_limit(ip: str):
60
  logger.warning(f"Rate limit exceeded for IP {ip}.")
61
  raise HTTPException(
62
  status_code=429,
63
- detail=f"Rate limit exceeded. Maximum {REQUEST_LIMIT_PER_MINUTE} requests per minute allowed."
64
  )
65
 
66
  # Helper function to create chat completion data
 
6
  import string
7
  from typing import Any, Dict, Optional
8
  import os
9
+ from fastapi import HTTPException, Request, Response
10
+ from fastapi.responses import JSONResponse
11
  from dotenv import load_dotenv
12
 
13
  import httpx
 
61
  logger.warning(f"Rate limit exceeded for IP {ip}.")
62
  raise HTTPException(
63
  status_code=429,
64
+ detail={"error": {"message": "Rate limit exceeded. Please wait and try again.", "type": "rate_limit"}},
65
  )
66
 
67
  # Helper function to create chat completion data