File size: 7,745 Bytes
80901e6 cda83bf b7b397e 26ca950 b7b397e e19b30e cda83bf 85ebef7 cda83bf 85ebef7 7c66e2d cda83bf e19b30e cda83bf 7c66e2d cda83bf 85ebef7 cda83bf 85ebef7 cda83bf b7b397e cda83bf 85ebef7 cda83bf 85ebef7 cda83bf 85ebef7 cda83bf 85ebef7 cda83bf b7b397e cda83bf e19b30e b7b397e cda83bf 85ebef7 cda83bf 85ebef7 cda83bf 85ebef7 cda83bf |
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
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()
|