(feat) support max_user_budget

This commit is contained in:
ishaan-jaff 2024-02-06 15:19:36 -08:00
parent 33aee6ba83
commit 4de77018cc
2 changed files with 47 additions and 6 deletions

View file

@ -1213,6 +1213,28 @@ async def reset_budget(prisma_client: PrismaClient):
)
async def _read_request_body(request):
"""
Asynchronous function to read the request body and parse it as JSON or literal data.
Parameters:
- request: The request object to read the body from
Returns:
- dict: Parsed request data as a dictionary
"""
import ast, json
request_data = {}
body = await request.body()
body_str = body.decode()
try:
request_data = ast.literal_eval(body_str)
except:
request_data = json.loads(body_str)
return request_data
# LiteLLM Admin UI - Non SSO Login
html_form = """
<!DOCTYPE html>