forked from phoenix/litellm-mirror
feat(proxy_server.py): add setup instructions for UI
This commit is contained in:
parent
18f8287e29
commit
2af4948af4
2 changed files with 79 additions and 1 deletions
|
@ -91,6 +91,7 @@ from litellm.proxy.utils import (
|
||||||
reset_budget,
|
reset_budget,
|
||||||
hash_token,
|
hash_token,
|
||||||
html_form,
|
html_form,
|
||||||
|
missing_keys_html_form,
|
||||||
_read_request_body,
|
_read_request_body,
|
||||||
_is_valid_team_configs,
|
_is_valid_team_configs,
|
||||||
_is_user_proxy_admin,
|
_is_user_proxy_admin,
|
||||||
|
@ -5140,6 +5141,13 @@ async def moderations(
|
||||||
|
|
||||||
#### DEV UTILS ####
|
#### DEV UTILS ####
|
||||||
|
|
||||||
|
# @router.get(
|
||||||
|
# "/utils/available_routes",
|
||||||
|
# tags=["llm utils"],
|
||||||
|
# dependencies=[Depends(user_api_key_auth)],
|
||||||
|
# )
|
||||||
|
# async def get_available_routes(user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth)):
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/utils/token_counter",
|
"/utils/token_counter",
|
||||||
|
@ -9582,7 +9590,8 @@ async def google_login(request: Request):
|
||||||
PROXY_BASE_URL should be the your deployed proxy endpoint, e.g. PROXY_BASE_URL="https://litellm-production-7002.up.railway.app/"
|
PROXY_BASE_URL should be the your deployed proxy endpoint, e.g. PROXY_BASE_URL="https://litellm-production-7002.up.railway.app/"
|
||||||
Example:
|
Example:
|
||||||
"""
|
"""
|
||||||
global premium_user
|
global premium_user, prisma_client, master_key
|
||||||
|
|
||||||
microsoft_client_id = os.getenv("MICROSOFT_CLIENT_ID", None)
|
microsoft_client_id = os.getenv("MICROSOFT_CLIENT_ID", None)
|
||||||
google_client_id = os.getenv("GOOGLE_CLIENT_ID", None)
|
google_client_id = os.getenv("GOOGLE_CLIENT_ID", None)
|
||||||
generic_client_id = os.getenv("GENERIC_CLIENT_ID", None)
|
generic_client_id = os.getenv("GENERIC_CLIENT_ID", None)
|
||||||
|
@ -9601,6 +9610,12 @@ async def google_login(request: Request):
|
||||||
code=status.HTTP_403_FORBIDDEN,
|
code=status.HTTP_403_FORBIDDEN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
####### Detect DB + MASTER KEY in .env #######
|
||||||
|
if prisma_client is None and master_key is None:
|
||||||
|
from fastapi.responses import HTMLResponse
|
||||||
|
|
||||||
|
return HTMLResponse(content=missing_keys_html_form, status_code=200)
|
||||||
|
|
||||||
# get url from request
|
# get url from request
|
||||||
redirect_url = os.getenv("PROXY_BASE_URL", str(request.base_url))
|
redirect_url = os.getenv("PROXY_BASE_URL", str(request.base_url))
|
||||||
ui_username = os.getenv("UI_USERNAME")
|
ui_username = os.getenv("UI_USERNAME")
|
||||||
|
|
|
@ -2713,3 +2713,66 @@ html_form = """
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
missing_keys_html_form = """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f4f4f9;
|
||||||
|
color: #333;
|
||||||
|
margin: 20px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: auto;
|
||||||
|
padding: 20px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
background: #f8f8f8;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow-x: auto;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.env-var {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
.comment {
|
||||||
|
font-weight: normal;
|
||||||
|
color: #777;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<title>Environment Setup Instructions</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>Environment Setup Instructions</h1>
|
||||||
|
<p>Please add the following configurations to your environment variables:</p>
|
||||||
|
<pre>
|
||||||
|
<span class="env-var">LITELLM_MASTER_KEY="sk-1234"</span> <span class="comment"># make this unique. must start with `sk-`.</span>
|
||||||
|
<span class="env-var">DATABASE_URL="postgres://..."</span> <span class="comment"># Need a postgres database? (Check out Supabase, Neon, etc)</span>
|
||||||
|
|
||||||
|
<span class="comment">## OPTIONAL ##</span>
|
||||||
|
<span class="env-var">PORT=4000</span> <span class="comment"># DO THIS FOR RENDER/RAILWAY</span>
|
||||||
|
<span class="env-var">STORE_MODEL_IN_DB="True"</span> <span class="comment"># Allow storing models in db</span>
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue