Spaces:
Sleeping
Sleeping
File size: 2,141 Bytes
74dd3f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import streamlit as st
import os
from utils.auth import check_authentication, logout
from components.sidebar import render_sidebar
from pages.home import render_home
from pages.model_details import render_model_details
from pages.repository_management import render_repository_management
from pages.analytics import render_analytics_page # Added import for analytics page
from pages.batch_operations import render_batch_operations # Added import for batch operations page
# Set page configuration
st.set_page_config(
page_title="HF Model Manager",
page_icon="🤗",
layout="wide",
initial_sidebar_state="expanded",
)
# Apply custom CSS
with open(".streamlit/styles.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
# Initialize session state
if "authenticated" not in st.session_state:
st.session_state.authenticated = False
if "page" not in st.session_state:
st.session_state.page = "home"
if "selected_model" not in st.session_state:
st.session_state.selected_model = None
if "models" not in st.session_state:
st.session_state.models = []
if "api_token" not in st.session_state:
st.session_state.api_token = None
def main():
# Check authentication
if not st.session_state.authenticated:
check_authentication()
else:
# Render sidebar
render_sidebar()
# Render selected page
if st.session_state.page == "home":
render_home()
elif st.session_state.page == "model_details":
render_model_details()
elif st.session_state.page == "repository_management":
render_repository_management()
elif st.session_state.page == "analytics":
render_analytics_page()
elif st.session_state.page == "batch_operations": # Added routing for batch operations page
render_batch_operations()
if __name__ == "__main__":
# Check if we have the Hugging Face token in secrets
if not st.session_state.get("api_token") and os.environ.get("HF_TOKEN"):
st.session_state.api_token = os.environ.get("HF_TOKEN")
st.rerun()
main() |