forked from phoenix/litellm-mirror
v0 view spend logs
This commit is contained in:
parent
b40176810e
commit
2f11b92698
1 changed files with 39 additions and 0 deletions
39
ui/admin.py
39
ui/admin.py
|
@ -178,6 +178,42 @@ def list_models():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def usage_stats():
|
||||||
|
import streamlit as st
|
||||||
|
import requests
|
||||||
|
|
||||||
|
# Check if the necessary configuration is available
|
||||||
|
if (
|
||||||
|
st.session_state.get("api_url", None) is not None
|
||||||
|
and st.session_state.get("proxy_key", None) is not None
|
||||||
|
):
|
||||||
|
# Make the GET request
|
||||||
|
try:
|
||||||
|
complete_url = ""
|
||||||
|
if isinstance(st.session_state["api_url"], str) and st.session_state[
|
||||||
|
"api_url"
|
||||||
|
].endswith("/"):
|
||||||
|
complete_url = f"{st.session_state['api_url']}models"
|
||||||
|
else:
|
||||||
|
complete_url = f"{st.session_state['api_url']}/models"
|
||||||
|
response = requests.get(
|
||||||
|
complete_url,
|
||||||
|
headers={"Authorization": f"Bearer {st.session_state['proxy_key']}"},
|
||||||
|
)
|
||||||
|
# Check if the request was successful
|
||||||
|
if response.status_code == 200:
|
||||||
|
models = response.json()
|
||||||
|
st.write(models) # or st.json(models) to pretty print the JSON
|
||||||
|
else:
|
||||||
|
st.error(f"Failed to get models. Status code: {response.status_code}")
|
||||||
|
except Exception as e:
|
||||||
|
st.error(f"An error occurred while requesting models: {e}")
|
||||||
|
else:
|
||||||
|
st.warning(
|
||||||
|
"Please configure the Proxy Endpoint and Proxy Key on the Proxy Setup page."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_key():
|
def create_key():
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
import json, requests, uuid
|
import json, requests, uuid
|
||||||
|
@ -338,6 +374,7 @@ def admin_page(is_admin="NOT_GIVEN"):
|
||||||
"Add Models",
|
"Add Models",
|
||||||
"List Models",
|
"List Models",
|
||||||
"Create Key",
|
"Create Key",
|
||||||
|
"Usage Stats",
|
||||||
"End-User Auth",
|
"End-User Auth",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -369,6 +406,8 @@ def admin_page(is_admin="NOT_GIVEN"):
|
||||||
list_models()
|
list_models()
|
||||||
elif page == "Create Key":
|
elif page == "Create Key":
|
||||||
create_key()
|
create_key()
|
||||||
|
elif page == "Usage Stats":
|
||||||
|
usage_stats()
|
||||||
|
|
||||||
|
|
||||||
admin_page()
|
admin_page()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue