import streamlit as st import json from copilot import build_global_graph # Build global graph once global_app = build_global_graph() st.set_page_config( page_title="AI Marketing Copilot", page_icon="🤖", layout="centered", initial_sidebar_state="collapsed", ) # --- HEADER --- st.image("logo.png", width=150) # <- replace with your project logo st.title("AI Marketing Copilot") st.markdown("Your intelligent assistant for **post generation & scheduling** ✨") st.divider() # --- PRODUCT INPUT FORM --- st.subheader("🛒 Product Information") with st.form("product_form"): # Required fields product_id = st.text_input("Product ID *", "PEN0001") product_name = st.text_input("Product Name *", "EcoWave Stainless Steel Insulated Bottle") product_category = st.text_input("Category *", "Drinkware") product_description = st.text_area( "Description *", "Durable, eco-friendly insulated bottle for everyday use." ) # Optional fields in expander with st.expander("🔧 Advanced fields (optional)"): product_type = st.text_input("Type", "Bottle") product_price = st.text_input("Price", "24.99") product_currency = st.text_input("Currency", "USD") product_stock = st.number_input("Stock Quantity", value=42, step=1) product_sku = st.text_input("SKU", "ECO-SS-500") product_options = st.text_area( "Options (JSON list)", '[{"name": "Size", "value": "500ml"}]' ) product_on_sale = st.checkbox("On Sale?", value=True) # Platform selection platform = st.selectbox("📱 Target Platform *", ["Instagram", "Twitter", "Facebook", "LinkedIn", "TikTok"]) submitted = st.form_submit_button("🚀 Generate & Schedule") if submitted: try: # Parse options safely try: options = json.loads(product_options) if not isinstance(options, list): options = [] except Exception: options = [] # Build product dict product = { "id": product_id, "name": product_name, "category": product_category, "type": product_type, "price": product_price, "currency": product_currency, "description": product_description, "stock_quantity": product_stock, "sku": product_sku, "images": [], "options": options, "on_sale": product_on_sale, } # Templates placeholder (normally loaded from DB) templates = [] with st.spinner("🤖 Generating post and scheduling..."): state = { "product": product, "platform": platform, "templates": templates, } result = global_app.invoke(state) st.success("✅ Post Generated & Scheduled!") # --- MAIN OUTPUT CARD --- st.subheader("📢 Final Post") final_post = result.get("final_post_struct", {}).get("post_text", "⚠️ No post generated") st.markdown( f"""
{final_post}