Spaces:
Sleeping
Sleeping
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() |