mgbam commited on
Commit
9140d68
Β·
verified Β·
1 Parent(s): 89f5c28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -39
app.py CHANGED
@@ -1,8 +1,11 @@
 
 
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
@@ -14,7 +17,9 @@ st.set_page_config(
14
  initial_sidebar_state="expanded",
15
  )
16
 
17
- # Define your navigation pages and labels here
 
 
18
  PAGES = {
19
  "Home": "🏠 Home",
20
  "Launch": "πŸš€ Launch",
@@ -22,27 +27,19 @@ PAGES = {
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
 
@@ -51,7 +48,6 @@ st.session_state.current_page = render_sidebar()
51
  # ────────────────────────────────────────────────────────────────────────────────
52
  def main():
53
  page = st.session_state.current_page
54
-
55
  if page == "Home":
56
  render_home()
57
  elif page == "Launch":
@@ -67,12 +63,10 @@ def main():
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>
@@ -83,38 +77,61 @@ def render_home():
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`
@@ -126,18 +143,7 @@ def render_settings():
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("---")
 
1
+ import os
2
+
3
  import streamlit as st
4
  from landing import show_landing_content
5
  from agent_manager import AgentManager
6
  from dashboard.logs import show_logs
7
  from stripe_checkout import create_stripe_session
8
+ from shopify_client import create_shopify_product
9
 
10
  # ────────────────────────────────────────────────────────────────────────────────
11
  # 1. GLOBAL CONFIGURATION
 
17
  initial_sidebar_state="expanded",
18
  )
19
 
20
+ # ────────────────────────────────────────────────────────────────────────────────
21
+ # 2. NAVIGATION SETUP
22
+ # ────────────────────────────────────────────────────────────────────────────────
23
  PAGES = {
24
  "Home": "🏠 Home",
25
  "Launch": "πŸš€ Launch",
 
27
  "Settings": "βš™οΈ Settings"
28
  }
29
 
 
30
  if "current_page" not in st.session_state:
31
  st.session_state.current_page = "Home"
32
 
 
 
 
33
  def render_sidebar() -> str:
 
34
  st.sidebar.title("AutoExec AI")
35
  choice = st.sidebar.radio(
36
+ "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
+ # reverse‐lookup internal key
42
+ return next(k for k, v in PAGES.items() if v == choice)
 
 
 
43
 
44
  st.session_state.current_page = render_sidebar()
45
 
 
48
  # ────────────────────────────────────────────────────────────────────────────────
49
  def main():
50
  page = st.session_state.current_page
 
51
  if page == "Home":
52
  render_home()
53
  elif page == "Launch":
 
63
  # 4. PAGE RENDERERS
64
  # ────────────────────────────────────────────────────────────────────────────────
65
  def render_home():
 
 
66
  st.markdown(
67
  """
68
  <div style="text-align:center; margin:2rem 0;">
69
+ <h1 style="font-size:3rem;">πŸš€ AutoExec AI</h1>
70
  <p style="font-size:1.25rem; color:#555;">
71
  Launch, manage, and optimize AI‑powered businesses with a single click.
72
  </p>
 
77
  show_landing_content()
78
 
79
  def render_launch():
 
80
  st.markdown("## πŸš€ Launch a New AI Business")
81
+ with st.form("launch_form"):
82
  niche = st.text_input(
83
+ "🎯 Niche",
84
  placeholder="e.g., fitness wear",
85
  help="Define the market or audience for your business.",
86
  )
87
  business_type = st.selectbox(
88
+ "πŸ“¦ Business Type",
89
  options=["Dropshipping", "Print-on-Demand", "Newsletter", "Course"],
90
+ help="Select the type of business model to generate.",
91
  )
92
  submit = st.form_submit_button("Generate & Deploy")
93
 
94
  if submit:
95
  if not niche.strip():
96
+ st.warning("Please enter a valid niche.")
97
  return
98
+
99
+ # 1) Run the AI agents
100
+ with st.spinner("πŸ€– Running AI agents..."):
101
+ manager = AgentManager(niche.strip(), business_type)
102
+ results = manager.run_all()
103
+ st.success("βœ… Business Launched Successfully!")
104
+ st.json(results)
105
+
106
+ # 2) Publish to Shopify
107
+ st.markdown("### πŸ›οΈ Publishing Product to Shopify")
108
+ product_title = f"{business_type} in {niche}"
109
+ product_desc = results.get("copy", "")
110
+ price_str = "49.00" # default price
111
+ image_url = None
112
+
113
+ try:
114
+ shopify_url = create_shopify_product(
115
+ title=product_title,
116
+ description=product_desc,
117
+ price=price_str,
118
+ image_url=image_url
119
+ )
120
+ st.success("πŸŽ‰ Product published to Shopify!")
121
+ st.markdown(f"[View your live product β†’]({shopify_url})")
122
+ except Exception as e:
123
+ st.error(f"❌ Shopify publish failed: {e}")
124
 
125
  def render_logs():
 
126
  st.markdown("## πŸ“Š Agent Memory Log Dashboard")
127
  show_logs()
128
 
129
  def render_settings():
 
130
  st.markdown("## βš™οΈ Settings & Billing")
131
  st.markdown(
132
  """
133
+ **Ensure the following secrets are set** under
134
+ Settings β†’ Secrets:
135
  - `API_KEY`
136
  - `OPENAI_API_KEY`
137
  - `GEMINI_API_KEY`
 
143
  st.markdown(f"[Proceed to Payment]({session_url})", unsafe_allow_html=True)
144
 
145
  # ────────────────────────────────────────────────────────────────────────────────
146
+ # 5. FOOTER
 
 
 
 
 
 
 
 
 
 
 
147
  # ────────────────────────────────────────────────────────────────────────────────
148
  def render_footer():
149
  st.markdown("---")