Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from landing import
|
| 3 |
from agent_manager import AgentManager
|
| 4 |
from dashboard.logs import show_logs
|
| 5 |
from stripe_checkout import create_stripe_session
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
| 8 |
st.set_page_config(
|
| 9 |
page_title="AutoExec AI",
|
| 10 |
page_icon="π",
|
|
@@ -12,10 +14,7 @@ st.set_page_config(
|
|
| 12 |
initial_sidebar_state="expanded",
|
| 13 |
)
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
if "page" not in st.session_state:
|
| 17 |
-
st.session_state.page = "Home"
|
| 18 |
-
|
| 19 |
PAGES = {
|
| 20 |
"Home": "π Home",
|
| 21 |
"Launch": "π Launch",
|
|
@@ -23,79 +22,137 @@ PAGES = {
|
|
| 23 |
"Settings": "βοΈ Settings"
|
| 24 |
}
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
st.markdown(
|
| 42 |
"""
|
| 43 |
-
<div style="text-align:center; margin:
|
| 44 |
-
<h1 style="font-size:3rem;">π AutoExec AI</h1>
|
| 45 |
-
<p style="font-size:1.25rem; color
|
| 46 |
-
|
| 47 |
-
Launch, manage, and optimize digital businesses in one click.
|
| 48 |
</p>
|
| 49 |
</div>
|
| 50 |
""",
|
| 51 |
unsafe_allow_html=True,
|
| 52 |
)
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
|
|
|
| 57 |
with st.form("launch_form", clear_on_submit=False):
|
| 58 |
-
niche = st.text_input(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
business_type = st.selectbox(
|
| 60 |
-
"π¦ Business Type",
|
| 61 |
-
["Dropshipping", "Print-on-Demand", "Newsletter", "Course"],
|
|
|
|
| 62 |
)
|
| 63 |
-
|
| 64 |
-
|
|
|
|
| 65 |
if not niche.strip():
|
| 66 |
-
st.
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
manager = AgentManager(niche.strip(), business_type)
|
| 70 |
-
result = manager.run_all()
|
| 71 |
-
st.success("β
Business Launched!")
|
| 72 |
-
st.json(result)
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
show_logs()
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
st.markdown(
|
| 81 |
"""
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
- `
|
| 85 |
-
- `
|
| 86 |
-
- `GEMINI_API_KEY`
|
| 87 |
- `STRIPE_API_KEY`
|
| 88 |
"""
|
| 89 |
)
|
| 90 |
if st.button("π³ Create Stripe Checkout Session"):
|
| 91 |
-
|
| 92 |
-
st.markdown(f"[Proceed to Payment]({
|
| 93 |
|
| 94 |
-
#
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
"
|
| 99 |
-
"
|
| 100 |
-
|
| 101 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from landing import show_landing_content
|
| 3 |
from agent_manager import AgentManager
|
| 4 |
from dashboard.logs import show_logs
|
| 5 |
from stripe_checkout import create_stripe_session
|
| 6 |
|
| 7 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
+
# 1. GLOBAL CONFIGURATION
|
| 9 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 10 |
st.set_page_config(
|
| 11 |
page_title="AutoExec AI",
|
| 12 |
page_icon="π",
|
|
|
|
| 14 |
initial_sidebar_state="expanded",
|
| 15 |
)
|
| 16 |
|
| 17 |
+
# Define your navigation pages and labels here
|
|
|
|
|
|
|
|
|
|
| 18 |
PAGES = {
|
| 19 |
"Home": "π Home",
|
| 20 |
"Launch": "π Launch",
|
|
|
|
| 22 |
"Settings": "βοΈ Settings"
|
| 23 |
}
|
| 24 |
|
| 25 |
+
# Initialize state
|
| 26 |
+
if "current_page" not in st.session_state:
|
| 27 |
+
st.session_state.current_page = "Home"
|
| 28 |
+
|
| 29 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 30 |
+
# 2. SIDEBAR NAVIGATION COMPONENT
|
| 31 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 32 |
+
def render_sidebar() -> str:
|
| 33 |
+
"""Renders the sidebar and returns the selected page key."""
|
| 34 |
+
st.sidebar.title("AutoExec AI")
|
| 35 |
+
choice = st.sidebar.radio(
|
| 36 |
+
label="Navigate to:",
|
| 37 |
+
options=list(PAGES.values()),
|
| 38 |
+
index=list(PAGES.values()).index(PAGES[st.session_state.current_page]),
|
| 39 |
+
key="nav_radio",
|
| 40 |
+
)
|
| 41 |
+
# Map label back to internal key
|
| 42 |
+
for key, label in PAGES.items():
|
| 43 |
+
if label == choice:
|
| 44 |
+
return key
|
| 45 |
+
return "Home"
|
| 46 |
+
|
| 47 |
+
st.session_state.current_page = render_sidebar()
|
| 48 |
|
| 49 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 50 |
+
# 3. PAGE DISPATCHER
|
| 51 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
+
def main():
|
| 53 |
+
page = st.session_state.current_page
|
| 54 |
|
| 55 |
+
if page == "Home":
|
| 56 |
+
render_home()
|
| 57 |
+
elif page == "Launch":
|
| 58 |
+
render_launch()
|
| 59 |
+
elif page == "Logs":
|
| 60 |
+
render_logs()
|
| 61 |
+
elif page == "Settings":
|
| 62 |
+
render_settings()
|
| 63 |
+
else:
|
| 64 |
+
st.error("Page not found!")
|
| 65 |
+
|
| 66 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 67 |
+
# 4. PAGE RENDERERS
|
| 68 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 69 |
+
def render_home():
|
| 70 |
+
"""Renders the Home (Landing) page with hero and features."""
|
| 71 |
+
# Hero section
|
| 72 |
st.markdown(
|
| 73 |
"""
|
| 74 |
+
<div style="text-align:center; margin:2rem 0;">
|
| 75 |
+
<h1 style="font-size:3rem; margin-bottom:0.5rem;">π AutoExec AI</h1>
|
| 76 |
+
<p style="font-size:1.25rem; color:#555;">
|
| 77 |
+
Launch, manage, and optimize AIβpowered businesses with a single click.
|
|
|
|
| 78 |
</p>
|
| 79 |
</div>
|
| 80 |
""",
|
| 81 |
unsafe_allow_html=True,
|
| 82 |
)
|
| 83 |
+
show_landing_content()
|
| 84 |
|
| 85 |
+
def render_launch():
|
| 86 |
+
"""Renders the Launch page with a form to kick off the agent pipeline."""
|
| 87 |
+
st.markdown("## π Launch a New AI Business")
|
| 88 |
with st.form("launch_form", clear_on_submit=False):
|
| 89 |
+
niche = st.text_input(
|
| 90 |
+
label="π― Niche",
|
| 91 |
+
placeholder="e.g., fitness wear",
|
| 92 |
+
help="Define the market or audience for your business.",
|
| 93 |
+
)
|
| 94 |
business_type = st.selectbox(
|
| 95 |
+
label="π¦ Business Type",
|
| 96 |
+
options=["Dropshipping", "Print-on-Demand", "Newsletter", "Course"],
|
| 97 |
+
help="Select the kind of business model to generate.",
|
| 98 |
)
|
| 99 |
+
submit = st.form_submit_button("Generate & Deploy")
|
| 100 |
+
|
| 101 |
+
if submit:
|
| 102 |
if not niche.strip():
|
| 103 |
+
st.warning("Please enter a valid niche to continue.")
|
| 104 |
+
return
|
| 105 |
+
_run_agents(niche.strip(), business_type)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
def render_logs():
|
| 108 |
+
"""Renders the Logs dashboard."""
|
| 109 |
+
st.markdown("## π Agent Memory Log Dashboard")
|
| 110 |
show_logs()
|
| 111 |
|
| 112 |
+
def render_settings():
|
| 113 |
+
"""Renders the Settings & Billing page."""
|
| 114 |
+
st.markdown("## βοΈ Settings & Billing")
|
| 115 |
st.markdown(
|
| 116 |
"""
|
| 117 |
+
**Secrets to configure** (Settings β Secrets):
|
| 118 |
+
- `API_KEY`
|
| 119 |
+
- `OPENAI_API_KEY`
|
| 120 |
+
- `GEMINI_API_KEY`
|
|
|
|
| 121 |
- `STRIPE_API_KEY`
|
| 122 |
"""
|
| 123 |
)
|
| 124 |
if st.button("π³ Create Stripe Checkout Session"):
|
| 125 |
+
session_url = create_stripe_session()
|
| 126 |
+
st.markdown(f"[Proceed to Payment]({session_url})", unsafe_allow_html=True)
|
| 127 |
|
| 128 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 129 |
+
# 5. AGENT EXECUTION HELPER
|
| 130 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 131 |
+
def _run_agents(niche: str, business_type: str):
|
| 132 |
+
"""Internal helper to run the AgentManager and display results."""
|
| 133 |
+
with st.spinner("π€ Running AI agents... please wait"):
|
| 134 |
+
manager = AgentManager(niche, business_type)
|
| 135 |
+
results = manager.run_all()
|
| 136 |
+
st.success("β
Business Launched Successfully!")
|
| 137 |
+
st.json(results)
|
| 138 |
+
|
| 139 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 140 |
+
# 6. FOOTER
|
| 141 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 142 |
+
def render_footer():
|
| 143 |
+
st.markdown("---")
|
| 144 |
+
st.markdown(
|
| 145 |
+
"""
|
| 146 |
+
<div style="text-align:center; color:#888; font-size:0.9rem;">
|
| 147 |
+
Powered by Streamlit β’ FastAPI β’ Celery β’ Redis β’ Hugging Face Spaces
|
| 148 |
+
</div>
|
| 149 |
+
""",
|
| 150 |
+
unsafe_allow_html=True,
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 154 |
+
# ENTRY POINT
|
| 155 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 156 |
+
if __name__ == "__main__":
|
| 157 |
+
main()
|
| 158 |
+
render_footer()
|