AICEO / app.py
mgbam's picture
Update app.py
c5676bf verified
raw
history blame
7.44 kB
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
import requests # if you’re also firing webhooks/Zapier
# ────────────────────────────────────────────────────────────────────────────────
# 1. GLOBAL PAGE CONFIG
# ────────────────────────────────────────────────────────────────────────────────
st.set_page_config(
page_title="AutoExecΒ AI",
page_icon="πŸš€",
layout="wide",
initial_sidebar_state="expanded",
)
# ────────────────────────────────────────────────────────────────────────────────
# 2. NAVIGATION
# ────────────────────────────────────────────────────────────────────────────────
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"
)
# map back to key
st.session_state.page = next(k for k, v in PAGES.items() if v == selection)
# ────────────────────────────────────────────────────────────────────────────────
# 3. PAGE DISPATCHER
# ────────────────────────────────────────────────────────────────────────────────
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")
# ────────────────────────────────────────────────────────────────────────────────
# 4. PAGE RENDERERS
# ────────────────────────────────────────────────────────────────────────────────
def render_home():
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;">
Your Autonomous AI Business Builder<br>
Generate, deploy, and optimize startups 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("---")
if st.button("πŸ‘‰ Try the Demo"):
st.session_state.page = "Launch"
st.experimental_rerun()
def render_launch():
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
# Run agents
with st.spinner("πŸ€– Running AI agents…"):
manager = AgentManager(niche.strip(), business_type)
results = manager.run_all()
st.success("βœ… Business Launched Successfully!")
st.json(results)
# Publish product to Shopify
try:
title = f"{business_type} in {niche}"
description = results["copy"]
price = "49.00"
image_url = None # or provide a default URL
storefront_url = create_shopify_product(
title=title,
description=description,
price=price,
image_url=image_url
)
st.markdown(f"**πŸ›οΈ Product live on Shopify:** [View Product]({storefront_url})")
except Exception as e:
st.error(f"❌ Shopify publish failed: {e}")
def render_logs():
st.markdown("## πŸ“Š Agent Memory Log Dashboard")
show_logs()
def render_settings():
st.markdown("## βš™οΈ Settings & Billing")
st.markdown(
"""
**Configure these secrets in Settings β†’ Secrets**
β€’ `API_KEY`
β€’ `OPENAI_API_KEY`
β€’ `GEMINI_API_KEY`
β€’ `STRIPE_API_KEY`
"""
)
if st.button("πŸ’³ Subscribe via Stripe"):
checkout_url = create_stripe_session()
st.markdown(f"[Proceed to Payment β†’]({checkout_url})", unsafe_allow_html=True)
# ────────────────────────────────────────────────────────────────────────────────
# 5. FOOTER
# ────────────────────────────────────────────────────────────────────────────────
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,
)
# ────────────────────────────────────────────────────────────────────────────────
# 6. ENTRY POINT
# ────────────────────────────────────────────────────────────────────────────────
if __name__ == "__main__":
main()
render_footer()