CoolFace
Apppublic

prashanth-criodo/SPARC

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
persona_manager.py53 linesDownload Raw Back to components
1from typing import Dict, Optional, Any2import streamlit as st3 4class PersonaManager:5    def __init__(self):6        if 'personas' not in st.session_state:7            st.session_state.personas = []8        if 'content_history' not in st.session_state:9            st.session_state.content_history = []10 11    def create_persona_form(self) -> Optional[Dict]:12        """Display form for creating a new persona"""13        st.subheader("Create Target Persona")14        15        with st.form("persona_form"):16            role = st.text_input("Role/Occupation", placeholder="e.g., Data Engineer, Analytics Manager")17            experience = st.selectbox(18                "Experience Level",19                ["Entry Level", "Mid Level", "Senior Level", "Leadership"]20            )21            technical_proficiency = st.select_slider(22                "Technical Proficiency",23                options=["Basic", "Intermediate", "Advanced", "Expert"]24            )25            content_style = st.multiselect(26                "Preferred Content Style",27                ["Technical", "Strategic", "Practical", "Theoretical"]28            )29            30            pain_points = st.text_area(31                "Key Pain Points",32                placeholder="What challenges does this persona face?"33            )34            35            submitted = st.form_submit_button("Save Persona")36            37            if submitted:38                persona = {39                    "id": len(st.session_state.personas) + 1,40                    "role": role,41                    "experience": experience,42                    "technical_proficiency": technical_proficiency,43                    "content_style": content_style,44                    "pain_points": pain_points45                }46                st.session_state.personas.append(persona)47                st.success(f"Persona '{role}' saved successfully!")48                return persona49        return None50 51    def get_personas(self):52        """Return list of saved personas"""53        return st.session_state.personas