Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,9 @@ from agent_manager import AgentManager
|
|
| 5 |
from shopify_client import create_shopify_product
|
| 6 |
from dashboard.logs import show_logs
|
| 7 |
from stripe_checkout import create_stripe_session
|
| 8 |
-
import requests # if youβre also firing webhooks/Zapier
|
| 9 |
|
| 10 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 11 |
-
# 1. GLOBAL PAGE
|
| 12 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 13 |
st.set_page_config(
|
| 14 |
page_title="AutoExecΒ AI",
|
|
@@ -18,7 +17,7 @@ st.set_page_config(
|
|
| 18 |
)
|
| 19 |
|
| 20 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
-
# 2. NAVIGATION
|
| 22 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 23 |
PAGES = {
|
| 24 |
"Home": "π Home",
|
|
@@ -37,8 +36,8 @@ selection = st.sidebar.radio(
|
|
| 37 |
index=list(PAGES.values()).index(PAGES[st.session_state.page]),
|
| 38 |
key="nav_radio"
|
| 39 |
)
|
| 40 |
-
#
|
| 41 |
-
st.session_state.page = next(
|
| 42 |
|
| 43 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 44 |
# 3. PAGE DISPATCHER
|
|
@@ -60,35 +59,40 @@ def main():
|
|
| 60 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 61 |
# 4. PAGE RENDERERS
|
| 62 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 63 |
def render_home():
|
|
|
|
| 64 |
st.markdown(
|
| 65 |
"""
|
| 66 |
<div style="text-align:center; padding:2rem 0;">
|
| 67 |
<h1 style="font-size:3rem; margin:0;">π AutoExecΒ AI</h1>
|
| 68 |
<p style="font-size:1.25rem; color:#555;">
|
| 69 |
-
|
| 70 |
-
Generate, deploy, and optimize startups in one click.
|
| 71 |
</p>
|
| 72 |
</div>
|
| 73 |
-
""",
|
|
|
|
| 74 |
)
|
|
|
|
| 75 |
cols = st.columns(3)
|
| 76 |
features = [
|
| 77 |
-
("π€ LLM
|
| 78 |
-
("π LoopAgent",
|
| 79 |
-
("π Dashboard",
|
| 80 |
]
|
| 81 |
for col, (title, desc) in zip(cols, features):
|
| 82 |
col.subheader(title)
|
| 83 |
col.write(desc)
|
| 84 |
|
| 85 |
st.markdown("---")
|
| 86 |
-
|
| 87 |
st.session_state.page = "Launch"
|
| 88 |
-
|
| 89 |
|
| 90 |
def render_launch():
|
|
|
|
| 91 |
st.markdown("## π Launch a New AI Business")
|
|
|
|
| 92 |
with st.form("launch_form"):
|
| 93 |
niche = st.text_input("π― Niche", placeholder="e.g., fitness wear")
|
| 94 |
business_type = st.selectbox(
|
|
@@ -96,53 +100,58 @@ def render_launch():
|
|
| 96 |
["Dropshipping", "PrintβonβDemand", "Newsletter", "Course"]
|
| 97 |
)
|
| 98 |
submit = st.form_submit_button("Generate & Deploy")
|
|
|
|
| 99 |
if submit:
|
| 100 |
if not niche.strip():
|
| 101 |
st.warning("Please enter a niche to continue.")
|
| 102 |
return
|
| 103 |
|
| 104 |
-
# Run
|
| 105 |
with st.spinner("π€ Running AI agentsβ¦"):
|
| 106 |
manager = AgentManager(niche.strip(), business_type)
|
| 107 |
results = manager.run_all()
|
| 108 |
-
|
| 109 |
st.success("β
Business Launched Successfully!")
|
| 110 |
st.json(results)
|
| 111 |
|
| 112 |
-
# Publish
|
| 113 |
try:
|
| 114 |
-
title
|
| 115 |
description = results["copy"]
|
| 116 |
-
price
|
| 117 |
-
image_url = None # or provide a default URL
|
| 118 |
storefront_url = create_shopify_product(
|
| 119 |
title=title,
|
| 120 |
description=description,
|
| 121 |
price=price,
|
| 122 |
-
image_url=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
)
|
| 124 |
-
st.markdown(f"**ποΈ Product live on Shopify:** [View Product]({storefront_url})")
|
| 125 |
except Exception as e:
|
| 126 |
-
st.error(f"β Shopify
|
| 127 |
|
| 128 |
def render_logs():
|
|
|
|
| 129 |
st.markdown("## π Agent Memory Log Dashboard")
|
| 130 |
show_logs()
|
| 131 |
|
| 132 |
def render_settings():
|
|
|
|
| 133 |
st.markdown("## βοΈ Settings & Billing")
|
| 134 |
st.markdown(
|
| 135 |
"""
|
| 136 |
-
**Configure these secrets
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
"""
|
| 142 |
)
|
| 143 |
if st.button("π³ Subscribe via Stripe"):
|
| 144 |
-
|
| 145 |
-
st.markdown(f"[Proceed to Payment β]({
|
| 146 |
|
| 147 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 148 |
# 5. FOOTER
|
|
@@ -150,10 +159,12 @@ def render_settings():
|
|
| 150 |
def render_footer():
|
| 151 |
st.markdown("---")
|
| 152 |
st.markdown(
|
| 153 |
-
"
|
| 154 |
-
"
|
| 155 |
-
|
| 156 |
-
|
|
|
|
|
|
|
| 157 |
)
|
| 158 |
|
| 159 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 5 |
from shopify_client import create_shopify_product
|
| 6 |
from dashboard.logs import show_logs
|
| 7 |
from stripe_checkout import create_stripe_session
|
|
|
|
| 8 |
|
| 9 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 10 |
+
# 1. GLOBAL PAGE CONFIGURATION
|
| 11 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 12 |
st.set_page_config(
|
| 13 |
page_title="AutoExecΒ AI",
|
|
|
|
| 17 |
)
|
| 18 |
|
| 19 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 20 |
+
# 2. SIDEBAR NAVIGATION SETUP
|
| 21 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 22 |
PAGES = {
|
| 23 |
"Home": "π Home",
|
|
|
|
| 36 |
index=list(PAGES.values()).index(PAGES[st.session_state.page]),
|
| 37 |
key="nav_radio"
|
| 38 |
)
|
| 39 |
+
# Map the selection back to its key
|
| 40 |
+
st.session_state.page = next(key for key, label in PAGES.items() if label == selection)
|
| 41 |
|
| 42 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
# 3. PAGE DISPATCHER
|
|
|
|
| 59 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 60 |
# 4. PAGE RENDERERS
|
| 61 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 62 |
+
|
| 63 |
def render_home():
|
| 64 |
+
"""Render the Home page with hero and feature highlights."""
|
| 65 |
st.markdown(
|
| 66 |
"""
|
| 67 |
<div style="text-align:center; padding:2rem 0;">
|
| 68 |
<h1 style="font-size:3rem; margin:0;">π AutoExecΒ AI</h1>
|
| 69 |
<p style="font-size:1.25rem; color:#555;">
|
| 70 |
+
Generate, deploy, and optimize AIβpowered businesses in one click.
|
|
|
|
| 71 |
</p>
|
| 72 |
</div>
|
| 73 |
+
""",
|
| 74 |
+
unsafe_allow_html=True
|
| 75 |
)
|
| 76 |
+
|
| 77 |
cols = st.columns(3)
|
| 78 |
features = [
|
| 79 |
+
("π€ LLMβPowered", "Gemini Pro + GPTβ4 fallback"),
|
| 80 |
+
("π LoopAgent", "Daily autonomous optimizations"),
|
| 81 |
+
("π Dashboard", "Realβtime logs & analytics")
|
| 82 |
]
|
| 83 |
for col, (title, desc) in zip(cols, features):
|
| 84 |
col.subheader(title)
|
| 85 |
col.write(desc)
|
| 86 |
|
| 87 |
st.markdown("---")
|
| 88 |
+
def go_to_launch():
|
| 89 |
st.session_state.page = "Launch"
|
| 90 |
+
st.button("π Try the Demo", on_click=go_to_launch)
|
| 91 |
|
| 92 |
def render_launch():
|
| 93 |
+
"""Render the Launch page with a form to run the AI agents & publish product."""
|
| 94 |
st.markdown("## π Launch a New AI Business")
|
| 95 |
+
|
| 96 |
with st.form("launch_form"):
|
| 97 |
niche = st.text_input("π― Niche", placeholder="e.g., fitness wear")
|
| 98 |
business_type = st.selectbox(
|
|
|
|
| 100 |
["Dropshipping", "PrintβonβDemand", "Newsletter", "Course"]
|
| 101 |
)
|
| 102 |
submit = st.form_submit_button("Generate & Deploy")
|
| 103 |
+
|
| 104 |
if submit:
|
| 105 |
if not niche.strip():
|
| 106 |
st.warning("Please enter a niche to continue.")
|
| 107 |
return
|
| 108 |
|
| 109 |
+
# 1) Run AI Agents
|
| 110 |
with st.spinner("π€ Running AI agentsβ¦"):
|
| 111 |
manager = AgentManager(niche.strip(), business_type)
|
| 112 |
results = manager.run_all()
|
|
|
|
| 113 |
st.success("β
Business Launched Successfully!")
|
| 114 |
st.json(results)
|
| 115 |
|
| 116 |
+
# 2) Publish to Shopify
|
| 117 |
try:
|
| 118 |
+
title = f"{business_type} in {niche}"
|
| 119 |
description = results["copy"]
|
| 120 |
+
price = "49.00"
|
|
|
|
| 121 |
storefront_url = create_shopify_product(
|
| 122 |
title=title,
|
| 123 |
description=description,
|
| 124 |
price=price,
|
| 125 |
+
image_url=None
|
| 126 |
+
)
|
| 127 |
+
st.markdown(
|
| 128 |
+
f"**ποΈ Product Live on Shopify:** "
|
| 129 |
+
f"[View Product]({storefront_url})",
|
| 130 |
+
unsafe_allow_html=True
|
| 131 |
)
|
|
|
|
| 132 |
except Exception as e:
|
| 133 |
+
st.error(f"β Shopify publishing failed: {e}")
|
| 134 |
|
| 135 |
def render_logs():
|
| 136 |
+
"""Render the Logs dashboard page."""
|
| 137 |
st.markdown("## π Agent Memory Log Dashboard")
|
| 138 |
show_logs()
|
| 139 |
|
| 140 |
def render_settings():
|
| 141 |
+
"""Render the Settings & Billing page."""
|
| 142 |
st.markdown("## βοΈ Settings & Billing")
|
| 143 |
st.markdown(
|
| 144 |
"""
|
| 145 |
+
**Configure these secrets:**
|
| 146 |
+
- `API_KEY`
|
| 147 |
+
- `OPENAI_API_KEY`
|
| 148 |
+
- `GEMINI_API_KEY`
|
| 149 |
+
- `STRIPE_API_KEY`
|
| 150 |
"""
|
| 151 |
)
|
| 152 |
if st.button("π³ Subscribe via Stripe"):
|
| 153 |
+
url = create_stripe_session()
|
| 154 |
+
st.markdown(f"[Proceed to Payment β]({url})", unsafe_allow_html=True)
|
| 155 |
|
| 156 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 157 |
# 5. FOOTER
|
|
|
|
| 159 |
def render_footer():
|
| 160 |
st.markdown("---")
|
| 161 |
st.markdown(
|
| 162 |
+
"""
|
| 163 |
+
<div style="text-align:center; color:#888; font-size:0.85rem;">
|
| 164 |
+
Powered by Streamlit β’ FastAPI β’ Celery β’ Redis β’ Hugging Face Spaces
|
| 165 |
+
</div>
|
| 166 |
+
""",
|
| 167 |
+
unsafe_allow_html=True
|
| 168 |
)
|
| 169 |
|
| 170 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|