File size: 2,197 Bytes
331216f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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)")