Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from agents import agents | |
| from utils import chat_with_agent | |
| from memory import store_memory, recall_memory | |
| from database import add_user, save_agent, save_conversation | |
| from metrics import show_dashboard | |
| from marketplace import show_marketplace | |
| st.set_page_config(page_title="AgentForge", page_icon="π₯", layout="wide") | |
| st.sidebar.title("ForgeStudio β‘") | |
| page = st.sidebar.radio("Navigation", ["Chat", "Marketplace", "Metrics", "Pricing"]) | |
| # Simple sign-in | |
| user_email = st.sidebar.text_input("Your Email") | |
| if st.sidebar.button("Sign in"): | |
| add_user(user_email) | |
| st.session_state.user = user_email | |
| st.success(f"Welcome, {user_email}!") | |
| if "user" not in st.session_state: | |
| st.warning("Please sign in first.") | |
| st.stop() | |
| if page == "Chat": | |
| agent_choice = st.selectbox("Choose Your Agent", list(agents.keys()) + ["Create New Agent"]) | |
| if agent_choice == "Create New Agent": | |
| new_name = st.text_input("Agent Name") | |
| new_persona = st.text_area("Describe your agent's personality") | |
| if st.button("Save Agent"): | |
| save_agent(new_name, new_persona, st.session_state.user) | |
| st.success("Agent created!") | |
| agents[new_name] = {"persona": new_persona} | |
| agent_choice = new_name | |
| user_input = st.text_input("You:", "") | |
| if st.button("Send"): | |
| memories = recall_memory(agent_choice, user_input) | |
| context = "\n".join(memories[0]) if memories else "" | |
| prompt = f"{agents[agent_choice]['persona']}\nContext:\n{context}\nUser: {user_input}" | |
| ai_response = chat_with_agent(agents[agent_choice]['persona'], [], prompt) | |
| store_memory(agent_choice, user_input, ai_response) | |
| save_conversation(agent_choice, st.session_state.user, user_input, ai_response) | |
| st.markdown(f"π€ **{agent_choice}:** {ai_response}") | |
| elif page == "Marketplace": | |
| show_marketplace() | |
| elif page == "Metrics": | |
| show_dashboard() | |
| elif page == "Pricing": | |
| st.subheader("π AgentForge Pro") | |
| st.write("Upgrade for unlimited agents, memory, and marketplace publishing.") | |
| st.markdown("[Subscribe via Stripe β](https://buy.stripe.com/test_your_stripe_link)") |