""" streamlit_app.py ---------------- Streamlit-based web UI for the NORA Admissions Agent demo. Responsibilities: - Load sample applications - Allow the user to run the AdmissionsAgent through a web interface - Display reviewed applications, scores, and a leaderboard - Provide detailed applicant information and explanations """ import json import streamlit as st from agent.admissions_agent import AdmissionsAgent import time def load_applications(file_path: str) -> list: """ Load applications from a JSON file. Parameters ---------- file_path : str Path to the JSON file containing applications. Returns ------- list A list of application dictionaries. """ with open(file_path, "r") as f: return json.load(f) def display_applicant_card(applicant: dict, review: dict, rank: int = None): """ Display a detailed applicant card with review information. Parameters ---------- applicant : dict Original applicant data review : dict Review results from the agent rank : int, optional Ranking position """ with st.container(): col1, col2 = st.columns([1, 2]) with col1: if rank: st.markdown(f"### 🏆 #{rank}") st.markdown(f"**{applicant['name']}**") st.markdown(f"**GPA:** {applicant.get('gpa', 'N/A')}") st.markdown(f"**SAT:** {applicant.get('sat', 'N/A')}") with col2: if 'scores' in review: scores = review['scores'] col_a, col_b, col_c, col_d = st.columns(4) with col_a: st.metric("Academics", f"{scores.get('academics', {}).get('score', 'N/A')}/10") with col_b: st.metric("Activities", f"{scores.get('activities', {}).get('score', 'N/A')}/10") with col_c: st.metric("Essay", f"{scores.get('essay', {}).get('score', 'N/A')}/10") with col_d: st.metric("Recommendations", f"{scores.get('recommendations', {}).get('score', 'N/A')}/10") if 'total_score' in review: st.markdown(f"**🎯 Total Score: {review['total_score']}/10**") if 'summary' in review: with st.expander("📝 AI Analysis"): st.write(review['summary']) st.divider() # ===================== # Streamlit UI Layout # ===================== st.set_page_config( page_title="NORA Admissions Agent", page_icon="🎓", layout="wide", initial_sidebar_state="expanded" ) # Custom CSS for better styling st.markdown(""" """, unsafe_allow_html=True) # Header st.markdown('

🎓 NORA – Northeastern Admissions Agent

', unsafe_allow_html=True) st.markdown("""

AI-Powered Admissions Assistant

NORA evaluates student applications using advanced AI analysis across multiple criteria including academics, activities, essays, and recommendations.

""", unsafe_allow_html=True) # Sidebar st.sidebar.markdown("## 🎛️ Demo Controls") st.sidebar.markdown("---") # Demo options demo_mode = st.sidebar.selectbox( "Demo Mode", ["Full Review", "Quick Preview", "Individual Review"], help="Choose how to run the demo" ) # Initialize session state if 'agent' not in st.session_state: st.session_state.agent = None if 'reviewed_applicants' not in st.session_state: st.session_state.reviewed_applicants = [] if 'ranked_results' not in st.session_state: st.session_state.ranked_results = [] # Main content area if demo_mode == "Full Review": st.markdown("## 📊 Full Application Review") if st.sidebar.button("🚀 Start Full Review", type="primary"): with st.spinner("Initializing NORA Agent..."): st.session_state.agent = AdmissionsAgent() st.success("✅ Agent initialized successfully!") # Load and review applications applicants = load_applications("data/sample_applications.json") st.markdown("### 📄 Processing Applications...") progress_bar = st.progress(0) status_text = st.empty() reviewed = [] for idx, applicant in enumerate(applicants, start=1): status_text.text(f"Reviewing {applicant['name']}...") with st.spinner(f"Analyzing {applicant['name']}..."): review = st.session_state.agent.review_applicant(applicant) reviewed.append((applicant, review)) progress_bar.progress(idx / len(applicants)) time.sleep(0.5) # Add slight delay for demo effect st.session_state.reviewed_applicants = reviewed st.session_state.ranked_results = st.session_state.agent.rank_all() st.success(f"✅ Successfully reviewed {len(applicants)} applicants!") # Display results if available if st.session_state.reviewed_applicants: st.markdown("## 🏆 Final Rankings") # Top 3 highlight if st.session_state.ranked_results: top_3 = st.session_state.ranked_results[:3] col1, col2, col3 = st.columns(3) with col1: if len(top_3) > 0: st.markdown(f"""

🥇 1st Place

{top_3[0]['name']}

{top_3[0]['total_score']}/10

""", unsafe_allow_html=True) with col2: if len(top_3) > 1: st.markdown(f"""

🥈 2nd Place

{top_3[1]['name']}

{top_3[1]['total_score']}/10

""", unsafe_allow_html=True) with col3: if len(top_3) > 2: st.markdown(f"""

🥉 3rd Place

{top_3[2]['name']}

{top_3[2]['total_score']}/10

""", unsafe_allow_html=True) # Detailed applicant cards st.markdown("## 📋 Detailed Applicant Reviews") for i, (applicant, review) in enumerate(st.session_state.reviewed_applicants): # Find ranking rank = None for j, ranked in enumerate(st.session_state.ranked_results, 1): if ranked['name'] == applicant['name']: rank = j break display_applicant_card(applicant, review, rank) elif demo_mode == "Quick Preview": st.markdown("## ⚡ Quick Preview") st.markdown("See a sample of how NORA evaluates applicants without running the full review.") if st.sidebar.button("👀 Show Sample Review"): # Show sample data sample_applicant = { "name": "Sample Student", "gpa": 3.8, "sat": 1450, "activities": "Student Council President, Robotics Team Captain", "essay": "My journey in robotics has taught me the importance of innovation and teamwork...", "recommendation": "Strong recommendation highlighting leadership and technical skills" } sample_review = { "name": "Sample Student", "scores": { "academics": {"score": 8.5, "justification": "Strong GPA and SAT scores"}, "activities": {"score": 9.0, "justification": "Excellent leadership roles"}, "essay": {"score": 8.0, "justification": "Well-written and compelling"}, "recommendations": {"score": 8.5, "justification": "Strong endorsements"} }, "total_score": 8.5, "summary": "Sample Student demonstrates excellent academic performance combined with strong leadership experience. Their robotics involvement shows technical aptitude and teamwork skills." } display_applicant_card(sample_applicant, sample_review, 1) elif demo_mode == "Individual Review": st.markdown("## 👤 Individual Applicant Review") # Load sample applicants for selection applicants = load_applications("data/sample_applications.json") selected_applicant = st.selectbox( "Choose an applicant to review:", options=[app['name'] for app in applicants], format_func=lambda x: x ) if st.sidebar.button("🔍 Review Selected Applicant"): if st.session_state.agent is None: with st.spinner("Initializing agent..."): st.session_state.agent = AdmissionsAgent() # Find the selected applicant applicant_data = next(app for app in applicants if app['name'] == selected_applicant) with st.spinner(f"Reviewing {selected_applicant}..."): review = st.session_state.agent.review_applicant(applicant_data) st.success(f"✅ Review completed for {selected_applicant}!") display_applicant_card(applicant_data, review) # Footer st.markdown("---") st.markdown("""

🎓 NORA Admissions Agent - Northeastern University Demo

Powered by Google Gemini AI

""", unsafe_allow_html=True)