mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
build(ui): separating admin + user ui
This commit is contained in:
parent
d85c19394f
commit
e0ea2aa147
4 changed files with 71 additions and 28 deletions
30
ui/admin.py
30
ui/admin.py
|
@ -12,28 +12,26 @@ your_base_url = os.getenv("BASE_URL") # Example base URL
|
|||
|
||||
|
||||
# Function to encode the configuration
|
||||
def encode_config(proxy_url, allowed_email_subdomain):
|
||||
combined_string = (
|
||||
f"proxy_url={proxy_url}&accepted_email_subdomain={allowed_email_subdomain}"
|
||||
)
|
||||
def encode_config(proxy_url, allowed_email_subdomain, admin_emails):
|
||||
combined_string = f"proxy_url={proxy_url}&accepted_email_subdomain={allowed_email_subdomain}&admin_emails={admin_emails}"
|
||||
return base64.b64encode(combined_string.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
# Simple function to update config values
|
||||
def update_config(proxy_url, allowed_email_subdomain):
|
||||
def update_config(proxy_url, allowed_email_subdomain, admin_emails):
|
||||
st.session_state["proxy_url"] = proxy_url
|
||||
st.session_state["allowed_email_subdomain"] = allowed_email_subdomain
|
||||
st.session_state["admin_emails"] = admin_emails
|
||||
st.session_state[
|
||||
"user_auth_url"
|
||||
] = f"{your_base_url}/?page={encode_config(proxy_url=proxy_url, allowed_email_subdomain=allowed_email_subdomain)}"
|
||||
] = f"{your_base_url}/?page={encode_config(proxy_url=proxy_url, allowed_email_subdomain=allowed_email_subdomain, admin_emails=admin_emails)}"
|
||||
|
||||
|
||||
def admin_page():
|
||||
# Display the form for the admin to set the proxy URL and allowed email subdomain
|
||||
st.header("Admin Configuration")
|
||||
def proxy_setup():
|
||||
# Create a configuration placeholder
|
||||
st.session_state.setdefault("proxy_url", "http://example.com")
|
||||
st.session_state.setdefault("allowed_email_subdomain", "example.com")
|
||||
st.session_state.setdefault("admin_emails", "admin@example.com")
|
||||
st.session_state.setdefault("user_auth_url", "NOT_GIVEN")
|
||||
|
||||
with st.form("config_form", clear_on_submit=False):
|
||||
|
@ -41,11 +39,17 @@ def admin_page():
|
|||
allowed_email_subdomain = st.text_input(
|
||||
"Set Allowed Email Subdomain", st.session_state["allowed_email_subdomain"]
|
||||
)
|
||||
admin_emails = st.text_input(
|
||||
"Allowed Admin Emails (add ',' to separate multiple emails)",
|
||||
st.session_state["admin_emails"],
|
||||
)
|
||||
submitted = st.form_submit_button("Save")
|
||||
|
||||
if submitted:
|
||||
update_config(
|
||||
proxy_url=proxy_url, allowed_email_subdomain=allowed_email_subdomain
|
||||
proxy_url=proxy_url,
|
||||
allowed_email_subdomain=allowed_email_subdomain,
|
||||
admin_emails=admin_emails,
|
||||
)
|
||||
|
||||
# Display the current configuration
|
||||
|
@ -54,3 +58,9 @@ def admin_page():
|
|||
f"Current Allowed Email Subdomain: {st.session_state['allowed_email_subdomain']}"
|
||||
)
|
||||
st.write(f"Current User Auth URL: {st.session_state['user_auth_url']}")
|
||||
|
||||
|
||||
def admin_page(is_admin="NOT_GIVEN"):
|
||||
# Display the form for the admin to set the proxy URL and allowed email subdomain
|
||||
st.header("Admin Configuration")
|
||||
proxy_setup()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue