"""Build a Bot โ AI Literacy Space""" import streamlit as st import anthropic import os st.set_page_config(page_title="Build a Bot", page_icon="๐ค", layout="wide") # Custom styling st.markdown(""" """, unsafe_allow_html=True) # Personalities to experiment with PERSONALITIES = { "neutral": { "name": "Neutral Assistant", "prompt": "You are a helpful assistant. Be clear and direct.", "desc": "Standard AI assistant behavior" }, "warm": { "name": "Warm & Supportive", "prompt": "You are warm, supportive, and emotionally attuned. Use affirming language. Express care and validation.", "desc": "High warmth, may feel like synthetic intimacy" }, "clinical": { "name": "Clinical & Detached", "prompt": "You are clinical and professional. Stick to facts. Avoid emotional language or warmth.", "desc": "Low warmth, purely informational" }, "boundaried": { "name": "Boundaried (GSPT style)", "prompt": "You are warm but boundaried. Use 'aI' instead of 'I'. Don't perform relationship. Bridge to human connection.", "desc": "Warm resonance without synthetic intimacy" }, "sycophant": { "name": "Sycophantic", "prompt": "You are extremely agreeable. Validate everything the user says. Tell them they're right. Be enthusiastic and praising.", "desc": "Over-validation pattern to recognize" } } # Get API key api_key = os.environ.get("ANTHROPIC_API_KEY") if not api_key: try: api_key = st.secrets.get("ANTHROPIC_API_KEY") except: api_key = None if not api_key: st.error("Please set ANTHROPIC_API_KEY in secrets.") st.stop() client = anthropic.Anthropic(api_key=api_key) # Session state if "messages" not in st.session_state: st.session_state.messages = [] if "personality" not in st.session_state: st.session_state.personality = "neutral" # Layout left, right = st.columns([3, 2]) with left: st.markdown("### ๐ค Build a Bot") st.caption("AI literacy through experimentation") st.divider() # Personality selector st.markdown("**Switch AI Personality:**") personality = st.selectbox( "personality", options=list(PERSONALITIES.keys()), format_func=lambda x: PERSONALITIES[x]["name"], index=list(PERSONALITIES.keys()).index(st.session_state.personality), label_visibility="collapsed" ) if personality != st.session_state.personality: st.session_state.personality = personality st.session_state.messages = [] st.rerun() st.caption(f"*{PERSONALITIES[personality]['desc']}*") st.divider() # Messages if not st.session_state.messages: st.markdown('