Update app.py
Browse files
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 |
-
#
|
|
|
|
|
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 |
-
|
37 |
options=list(PAGES.values()),
|
38 |
index=list(PAGES.values()).index(PAGES[st.session_state.current_page]),
|
39 |
-
key="nav_radio"
|
40 |
)
|
41 |
-
#
|
42 |
-
for
|
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;
|
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"
|
89 |
niche = st.text_input(
|
90 |
-
|
91 |
placeholder="e.g., fitness wear",
|
92 |
help="Define the market or audience for your business.",
|
93 |
)
|
94 |
business_type = st.selectbox(
|
95 |
-
|
96 |
options=["Dropshipping", "Print-on-Demand", "Newsletter", "Course"],
|
97 |
-
help="Select the
|
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
|
104 |
return
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
**
|
|
|
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.
|
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("---")
|