AICEO / app.py
mgbam's picture
Update app.py
cda83bf verified
raw
history blame
7.75 kB
import streamlit as st
from landing import show_landing_content
from agent_manager import AgentManager
from dashboard.logs import show_logs
from stripe_checkout import create_stripe_session
# ────────────────────────────────────────────────────────────────────────────────
# 1. GLOBAL CONFIGURATION
# ────────────────────────────────────────────────────────────────────────────────
st.set_page_config(
page_title="AutoExec AI",
page_icon="πŸš€",
layout="wide",
initial_sidebar_state="expanded",
)
# Define your navigation pages and labels here
PAGES = {
"Home": "🏠 Home",
"Launch": "πŸš€ Launch",
"Logs": "πŸ“Š Logs",
"Settings": "βš™οΈ Settings"
}
# Initialize state
if "current_page" not in st.session_state:
st.session_state.current_page = "Home"
# ────────────────────────────────────────────────────────────────────────────────
# 2. SIDEBAR NAVIGATION COMPONENT
# ────────────────────────────────────────────────────────────────────────────────
def render_sidebar() -> str:
"""Renders the sidebar and returns the selected page key."""
st.sidebar.title("AutoExec AI")
choice = st.sidebar.radio(
label="Navigate to:",
options=list(PAGES.values()),
index=list(PAGES.values()).index(PAGES[st.session_state.current_page]),
key="nav_radio",
)
# Map label back to internal key
for key, label in PAGES.items():
if label == choice:
return key
return "Home"
st.session_state.current_page = render_sidebar()
# ────────────────────────────────────────────────────────────────────────────────
# 3. PAGE DISPATCHER
# ────────────────────────────────────────────────────────────────────────────────
def main():
page = st.session_state.current_page
if page == "Home":
render_home()
elif page == "Launch":
render_launch()
elif page == "Logs":
render_logs()
elif page == "Settings":
render_settings()
else:
st.error("Page not found!")
# ────────────────────────────────────────────────────────────────────────────────
# 4. PAGE RENDERERS
# ────────────────────────────────────────────────────────────────────────────────
def render_home():
"""Renders the Home (Landing) page with hero and features."""
# Hero section
st.markdown(
"""
<div style="text-align:center; margin:2rem 0;">
<h1 style="font-size:3rem; margin-bottom:0.5rem;">πŸš€ AutoExec AI</h1>
<p style="font-size:1.25rem; color:#555;">
Launch, manage, and optimize AI‑powered businesses with a single click.
</p>
</div>
""",
unsafe_allow_html=True,
)
show_landing_content()
def render_launch():
"""Renders the Launch page with a form to kick off the agent pipeline."""
st.markdown("## πŸš€ Launch a New AI Business")
with st.form("launch_form", clear_on_submit=False):
niche = st.text_input(
label="🎯 Niche",
placeholder="e.g., fitness wear",
help="Define the market or audience for your business.",
)
business_type = st.selectbox(
label="πŸ“¦ Business Type",
options=["Dropshipping", "Print-on-Demand", "Newsletter", "Course"],
help="Select the kind of business model to generate.",
)
submit = st.form_submit_button("Generate & Deploy")
if submit:
if not niche.strip():
st.warning("Please enter a valid niche to continue.")
return
_run_agents(niche.strip(), business_type)
def render_logs():
"""Renders the Logs dashboard."""
st.markdown("## πŸ“Š Agent Memory Log Dashboard")
show_logs()
def render_settings():
"""Renders the Settings & Billing page."""
st.markdown("## βš™οΈ Settings & Billing")
st.markdown(
"""
**Secrets to configure** (Settings β†’ Secrets):
- `API_KEY`
- `OPENAI_API_KEY`
- `GEMINI_API_KEY`
- `STRIPE_API_KEY`
"""
)
if st.button("πŸ’³ Create Stripe Checkout Session"):
session_url = create_stripe_session()
st.markdown(f"[Proceed to Payment]({session_url})", unsafe_allow_html=True)
# ────────────────────────────────────────────────────────────────────────────────
# 5. AGENT EXECUTION HELPER
# ────────────────────────────────────────────────────────────────────────────────
def _run_agents(niche: str, business_type: str):
"""Internal helper to run the AgentManager and display results."""
with st.spinner("πŸ€– Running AI agents... please wait"):
manager = AgentManager(niche, business_type)
results = manager.run_all()
st.success("βœ… Business Launched Successfully!")
st.json(results)
# ────────────────────────────────────────────────────────────────────────────────
# 6. FOOTER
# ────────────────────────────────────────────────────────────────────────────────
def render_footer():
st.markdown("---")
st.markdown(
"""
<div style="text-align:center; color:#888; font-size:0.9rem;">
Powered by Streamlit β€’ FastAPI β€’ Celery β€’ Redis β€’ Hugging Face Spaces
</div>
""",
unsafe_allow_html=True,
)
# ────────────────────────────────────────────────────────────────────────────────
# ENTRY POINT
# ────────────────────────────────────────────────────────────────────────────────
if __name__ == "__main__":
main()
render_footer()