import base64 from pathlib import Path import streamlit as st from dotenv import load_dotenv from app_pages.script_library import render_script_library from app_pages.video_analyser import render_video_analyser_page from app_pages.image_analyser import render_image_analyser_page from app_pages.image_analyser_library import render_image_analysis_library from app_pages.video_hashid_generation import render_video_hashid from app_pages.video_text_generation import render_video_to_text from app_pages.video_translator import render_video_translator from app_pages.video_caption import render_video_caption from authen.authentication import login_gate, logout from app_pages.text_image_generation import render_multimodel_ad_generator from app_pages.image_generation import render_bulk_image_generator from app_pages.video_library import render_video_library from app_pages.image_generation_library import render_image_variations_library from app_pages.text_image_generation_library import render_text_image_library from app_pages.script_generator import generator_page load_dotenv() st.set_page_config(page_title="Gen AI + AI Library", page_icon="✨", layout="wide") # ---------- Auth ---------- uid = login_gate() with st.sidebar: st.markdown(f"**Signed in as:** `{uid}`") if st.button("Log out", key="btn_logout",width='content'): logout() st.rerun() st.markdown( """ """, unsafe_allow_html=True, ) prev_private_mode = st.session_state.get("_private_mode_prev", st.session_state.get("private_mode_enabled", False)) banner_slot = st.empty() private_mode_default = st.session_state.get("private_mode_enabled", False) private_mode = st.toggle( "Private mode", value=private_mode_default, key="private_mode_enabled", help="Skip saving prompts, jobs, and generated media to shared libraries." ) just_enabled_private_mode = private_mode and not prev_private_mode just_disabled_private_mode = (not private_mode) and prev_private_mode if just_enabled_private_mode: st.markdown( """ """, unsafe_allow_html=True, ) icon_data_url = "" try: icon_path = Path(__file__).resolve().parent / "assets" / "private-mode.png" icon_data_url = "data:image/png;base64," + base64.b64encode(icon_path.read_bytes()).decode("utf-8") except Exception: icon_data_url = "" icon_html = f'Private mode icon' if icon_data_url else "" banner_slot.markdown( f"""
{icon_html}
Private mode is live for this session. We'll keep new generations off shared storage until you disable it.
""", unsafe_allow_html=True, ) elif just_disabled_private_mode: banner_slot.empty() st.session_state["_private_mode_prev"] = private_mode if private_mode: st.caption("Private mode keeps this session's generations ephemeral—nothing is stored in the AI Library or external storage.") section = st.radio(" ", ["Gen AI", "AI Library"], index=0, horizontal=True, key="main_section") # ---------------------------- Gen AI --------------------------------- def render_genai(): _, main = st.columns([0.1, 1], gap="small") with main: mod_tabs = st.tabs(["Image Gen","Image Analyser","Video Analyser", "Script Generator", "Video Hashid Gen", "Video to Text","Video Translator","Generate Caption"]) # -------- Image Generation -------- with mod_tabs[0]: sub = st.tabs(["Text", "Img"]) with sub[0]: render_multimodel_ad_generator() with sub[1]: render_bulk_image_generator(uid=uid) with mod_tabs[1]: render_image_analyser_page(uid=uid) # -------- Video Analyser -------- with mod_tabs[2]: render_video_analyser_page(uid=uid) # -------- Script Generator -------- with mod_tabs[3]: generator_page(uid=uid) #-------- Video Hashid Generation -------- with mod_tabs[4]: render_video_hashid(uid=uid) #-------- Video to Text Generation -------- with mod_tabs[5]: render_video_to_text(uid=uid) #-------- Video Translator -------- with mod_tabs[6]: render_video_translator(uid=uid) #-------- Video caption -------- with mod_tabs[7]: render_video_caption(uid=uid) # ---------------------------- AI Library --------------------------------- def render_ai_library(): _, main = st.columns([0.1, 1], gap="small") with main: st.subheader("Library") lib_tabs = st.tabs(["Image","Analysed Image","Analysed Video", "Generated Scripts"]) # ---------- Image Tab ---------- with lib_tabs[0]: sub = st.tabs(["New generated", "Variations"]) with sub[0]: render_text_image_library(uid=uid) with sub[1]: render_image_variations_library(uid=uid) with lib_tabs[1]: render_image_analysis_library(uid=uid) # ---------- Video Library Tab ---------- with lib_tabs[2]: render_video_library(uid=uid) # ---------- Generated Scripts Tab ---------- with lib_tabs[3]: render_script_library(uid=uid) if section == "Gen AI": render_genai() else: render_ai_library()