mgbam commited on
Commit
cda83bf
Β·
verified Β·
1 Parent(s): 85ebef7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +115 -58
app.py CHANGED
@@ -1,10 +1,12 @@
1
  import streamlit as st
2
- from landing import show_landing
3
  from agent_manager import AgentManager
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="πŸš€",
@@ -12,10 +14,7 @@ st.set_page_config(
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",
@@ -23,79 +22,137 @@ PAGES = {
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
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()