|
import os |
|
import streamlit as st |
|
from datetime import datetime |
|
from agent_manager import AgentManager |
|
from shopify_client import create_shopify_product |
|
from dashboard.logs import show_logs |
|
from stripe_checkout import create_stripe_session |
|
|
|
|
|
|
|
|
|
st.set_page_config( |
|
page_title="AutoExecΒ AI", |
|
page_icon="π", |
|
layout="wide", |
|
initial_sidebar_state="expanded", |
|
) |
|
|
|
|
|
|
|
|
|
PAGES = { |
|
"Home": "π Home", |
|
"Launch": "π Launch", |
|
"Logs": "π Logs", |
|
"Settings": "βοΈ Settings" |
|
} |
|
|
|
if "page" not in st.session_state: |
|
st.session_state.page = "Home" |
|
|
|
st.sidebar.title("AutoExecΒ AI") |
|
selection = st.sidebar.radio( |
|
"Navigate:", |
|
list(PAGES.values()), |
|
index=list(PAGES.values()).index(PAGES[st.session_state.page]), |
|
key="nav_radio" |
|
) |
|
|
|
st.session_state.page = next(key for key, label in PAGES.items() if label == selection) |
|
|
|
|
|
|
|
|
|
def main(): |
|
page = st.session_state.page |
|
|
|
if page == "Home": |
|
render_home() |
|
elif page == "Launch": |
|
render_launch() |
|
elif page == "Logs": |
|
render_logs() |
|
elif page == "Settings": |
|
render_settings() |
|
else: |
|
st.error("Page not found") |
|
|
|
|
|
|
|
|
|
|
|
def render_home(): |
|
"""Render the Home page with hero and feature highlights.""" |
|
st.markdown( |
|
""" |
|
<div style="text-align:center; padding:2rem 0;"> |
|
<h1 style="font-size:3rem; margin:0;">π AutoExecΒ AI</h1> |
|
<p style="font-size:1.25rem; color:#555;"> |
|
Generate, deploy, and optimize AIβpowered businesses in one click. |
|
</p> |
|
</div> |
|
""", |
|
unsafe_allow_html=True |
|
) |
|
|
|
cols = st.columns(3) |
|
features = [ |
|
("π€ LLMβPowered", "Gemini Pro + GPTβ4 fallback"), |
|
("π LoopAgent", "Daily autonomous optimizations"), |
|
("π Dashboard", "Realβtime logs & analytics") |
|
] |
|
for col, (title, desc) in zip(cols, features): |
|
col.subheader(title) |
|
col.write(desc) |
|
|
|
st.markdown("---") |
|
def go_to_launch(): |
|
st.session_state.page = "Launch" |
|
st.button("π Try the Demo", on_click=go_to_launch) |
|
|
|
def render_launch(): |
|
"""Render the Launch page with a form to run the AI agents & publish product.""" |
|
st.markdown("## π Launch a New AI Business") |
|
|
|
with st.form("launch_form"): |
|
niche = st.text_input("π― Niche", placeholder="e.g., fitness wear") |
|
business_type = st.selectbox( |
|
"π¦ Business Type", |
|
["Dropshipping", "PrintβonβDemand", "Newsletter", "Course"] |
|
) |
|
submit = st.form_submit_button("Generate & Deploy") |
|
|
|
if submit: |
|
if not niche.strip(): |
|
st.warning("Please enter a niche to continue.") |
|
return |
|
|
|
|
|
with st.spinner("π€ Running AI agentsβ¦"): |
|
manager = AgentManager(niche.strip(), business_type) |
|
results = manager.run_all() |
|
st.success("β
Business Launched Successfully!") |
|
st.json(results) |
|
|
|
|
|
try: |
|
title = f"{business_type} in {niche}" |
|
description = results["copy"] |
|
price = "49.00" |
|
storefront_url = create_shopify_product( |
|
title=title, |
|
description=description, |
|
price=price, |
|
image_url=None |
|
) |
|
st.markdown( |
|
f"**ποΈ Product Live on Shopify:** " |
|
f"[View Product]({storefront_url})", |
|
unsafe_allow_html=True |
|
) |
|
except Exception as e: |
|
st.error(f"β Shopify publishing failed: {e}") |
|
|
|
def render_logs(): |
|
"""Render the Logs dashboard page.""" |
|
st.markdown("## π Agent Memory Log Dashboard") |
|
show_logs() |
|
|
|
def render_settings(): |
|
"""Render the Settings & Billing page.""" |
|
st.markdown("## βοΈ Settings & Billing") |
|
st.markdown( |
|
""" |
|
**Configure these secrets:** |
|
- `API_KEY` |
|
- `OPENAI_API_KEY` |
|
- `GEMINI_API_KEY` |
|
- `STRIPE_API_KEY` |
|
""" |
|
) |
|
if st.button("π³ Subscribe via Stripe"): |
|
url = create_stripe_session() |
|
st.markdown(f"[Proceed to Payment β]({url})", unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
|
def render_footer(): |
|
st.markdown("---") |
|
st.markdown( |
|
""" |
|
<div style="text-align:center; color:#888; font-size:0.85rem;"> |
|
Powered by Streamlit β’ FastAPI β’ Celery β’ Redis β’ Hugging Face Spaces |
|
</div> |
|
""", |
|
unsafe_allow_html=True |
|
) |
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
main() |
|
render_footer() |
|
|