mgbam commited on
Commit
f761f01
Β·
verified Β·
1 Parent(s): 0e1fe30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -33
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 CONFIG
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
- # map back to key
41
- st.session_state.page = next(k for k, v in PAGES.items() if v == selection)
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
- Your Autonomous AI Business Builder<br>
70
- Generate, deploy, and optimize startups in one click.
71
  </p>
72
  </div>
73
- """, unsafe_allow_html=True
 
74
  )
 
75
  cols = st.columns(3)
76
  features = [
77
- ("πŸ€– LLM-Powered", "Gemini Pro + GPT‑4 fallback"),
78
- ("πŸ”„ LoopAgent", "Daily autonomous optimizations"),
79
- ("πŸ“Š Dashboard", "Real-time logs & analytics")
80
  ]
81
  for col, (title, desc) in zip(cols, features):
82
  col.subheader(title)
83
  col.write(desc)
84
 
85
  st.markdown("---")
86
- if st.button("πŸ‘‰ Try the Demo"):
87
  st.session_state.page = "Launch"
88
- st.experimental_rerun()
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 agents
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 product to Shopify
113
  try:
114
- title = f"{business_type} in {niche}"
115
  description = results["copy"]
116
- price = "49.00"
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=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 publish failed: {e}")
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 in Settings β†’ Secrets**
137
- β€’ `API_KEY`
138
- β€’ `OPENAI_API_KEY`
139
- β€’ `GEMINI_API_KEY`
140
- β€’ `STRIPE_API_KEY`
141
  """
142
  )
143
  if st.button("πŸ’³ Subscribe via Stripe"):
144
- checkout_url = create_stripe_session()
145
- st.markdown(f"[Proceed to Payment β†’]({checkout_url})", unsafe_allow_html=True)
146
 
147
  # ────────────────────────────────────────────────────────────────────────────────
148
  # 5. FOOTER
@@ -150,10 +159,12 @@ def render_settings():
150
  def render_footer():
151
  st.markdown("---")
152
  st.markdown(
153
- "<div style='text-align:center; color:#888; font-size:0.85rem;'>"
154
- "Powered by Streamlit β€’ FastAPI β€’ Celery β€’ Redis β€’ Hugging Face Spaces"
155
- "</div>",
156
- unsafe_allow_html=True,
 
 
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
  # ────────────────────────────────────────────────────────────────────────────────