Update app.py
Browse files
app.py
CHANGED
|
@@ -4,49 +4,98 @@ from agent_manager import AgentManager
|
|
| 4 |
from dashboard.logs import show_logs
|
| 5 |
from stripe_checkout import create_stripe_session
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
if "page" not in st.session_state:
|
| 9 |
st.session_state.page = "Home"
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
# Create a radio widget in the sidebar, keyed to 'page'
|
| 15 |
-
# This widget *updates* st.session_state.page automatically
|
| 16 |
st.sidebar.title("AutoExec AI")
|
| 17 |
-
st.sidebar.radio(
|
| 18 |
-
"
|
| 19 |
-
PAGES,
|
| 20 |
-
index=PAGES.index(st.session_state.page),
|
| 21 |
-
key="
|
| 22 |
)
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
page =
|
|
|
|
| 26 |
|
| 27 |
-
#
|
| 28 |
if page == "Home":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
show_landing()
|
| 30 |
|
| 31 |
elif page == "Launch":
|
| 32 |
-
st.
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
elif page == "Logs":
|
|
|
|
| 45 |
show_logs()
|
| 46 |
|
| 47 |
elif page == "Settings":
|
| 48 |
-
st.
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
url = create_stripe_session()
|
| 51 |
-
st.markdown(f"[
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from dashboard.logs import show_logs
|
| 5 |
from stripe_checkout import create_stripe_session
|
| 6 |
|
| 7 |
+
# βββ Page Configuration βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
+
st.set_page_config(
|
| 9 |
+
page_title="AutoExec AI",
|
| 10 |
+
page_icon="π",
|
| 11 |
+
layout="wide",
|
| 12 |
+
initial_sidebar_state="expanded",
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
# βββ Sidebar Navigation βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 16 |
if "page" not in st.session_state:
|
| 17 |
st.session_state.page = "Home"
|
| 18 |
|
| 19 |
+
PAGES = {
|
| 20 |
+
"Home": "π Home",
|
| 21 |
+
"Launch": "π Launch",
|
| 22 |
+
"Logs": "π Logs",
|
| 23 |
+
"Settings": "βοΈ Settings"
|
| 24 |
+
}
|
| 25 |
|
|
|
|
|
|
|
| 26 |
st.sidebar.title("AutoExec AI")
|
| 27 |
+
selection = st.sidebar.radio(
|
| 28 |
+
"Navigate to",
|
| 29 |
+
list(PAGES.values()),
|
| 30 |
+
index=list(PAGES.values()).index(PAGES[st.session_state.page]),
|
| 31 |
+
key="page_choice"
|
| 32 |
)
|
| 33 |
|
| 34 |
+
# Map back to internal page names
|
| 35 |
+
page = next(k for k, v in PAGES.items() if v == selection)
|
| 36 |
+
st.session_state.page = page
|
| 37 |
|
| 38 |
+
# βββ Main Content βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 39 |
if page == "Home":
|
| 40 |
+
# Full-bleed hero section
|
| 41 |
+
st.markdown(
|
| 42 |
+
"""
|
| 43 |
+
<div style="text-align:center; margin: 2rem 0;">
|
| 44 |
+
<h1 style="font-size:3rem;">π AutoExec AI</h1>
|
| 45 |
+
<p style="font-size:1.25rem; color: #666;">
|
| 46 |
+
Your Autonomous AI Business Builder<br>
|
| 47 |
+
Launch, manage, and optimize digital businesses in one click.
|
| 48 |
+
</p>
|
| 49 |
+
</div>
|
| 50 |
+
""",
|
| 51 |
+
unsafe_allow_html=True,
|
| 52 |
+
)
|
| 53 |
show_landing()
|
| 54 |
|
| 55 |
elif page == "Launch":
|
| 56 |
+
st.subheader("π Launch a New AI Business")
|
| 57 |
+
with st.form("launch_form", clear_on_submit=False):
|
| 58 |
+
niche = st.text_input("π― Niche", placeholder="e.g., fitness")
|
| 59 |
+
business_type = st.selectbox(
|
| 60 |
+
"π¦ Business Type",
|
| 61 |
+
["Dropshipping", "Print-on-Demand", "Newsletter", "Course"],
|
| 62 |
+
)
|
| 63 |
+
launched = st.form_submit_button("Generate & Deploy")
|
| 64 |
+
if launched:
|
| 65 |
+
if not niche.strip():
|
| 66 |
+
st.error("Please enter a valid niche.")
|
| 67 |
+
else:
|
| 68 |
+
with st.spinner("π€ Running agents... this takes a few seconds"):
|
| 69 |
+
manager = AgentManager(niche.strip(), business_type)
|
| 70 |
+
result = manager.run_all()
|
| 71 |
+
st.success("β
Business Launched!")
|
| 72 |
+
st.json(result)
|
| 73 |
|
| 74 |
elif page == "Logs":
|
| 75 |
+
st.subheader("π Agent Memory Log Dashboard")
|
| 76 |
show_logs()
|
| 77 |
|
| 78 |
elif page == "Settings":
|
| 79 |
+
st.subheader("βοΈ Settings & Billing")
|
| 80 |
+
st.markdown(
|
| 81 |
+
"""
|
| 82 |
+
Manage your API keys, subscriptions, and integrations.
|
| 83 |
+
Ensure youβve set the following in **Settings β Secrets**:
|
| 84 |
+
- `API_KEY`
|
| 85 |
+
- `OPENAI_API_KEY`
|
| 86 |
+
- `GEMINI_API_KEY`
|
| 87 |
+
- `STRIPE_API_KEY`
|
| 88 |
+
"""
|
| 89 |
+
)
|
| 90 |
+
if st.button("π³ Create Stripe Checkout Session"):
|
| 91 |
url = create_stripe_session()
|
| 92 |
+
st.markdown(f"[Proceed to Payment]({url})", unsafe_allow_html=True)
|
| 93 |
+
|
| 94 |
+
# βββ Footer βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 95 |
+
st.markdown("---")
|
| 96 |
+
st.markdown(
|
| 97 |
+
"<p style='text-align:center; color:#888; font-size:0.9rem;'>"
|
| 98 |
+
"Powered by Streamlit β’ FastAPI β’ Celery β’ Redis β’ Hugging Face Spaces"
|
| 99 |
+
"</p>",
|
| 100 |
+
unsafe_allow_html=True,
|
| 101 |
+
)
|