# utils.py """ Utility functions for the app """ import streamlit as st from typing import List, Dict, Any def display_agent_results(agents: List[Dict[str, Any]], agent_type: str = "selling"): """Display agent recommendations in a clean format""" if not agents: st.warning("No agents found matching your criteria.") return for agent in agents: with st.container(): col1, col2 = st.columns([2, 3]) with col1: st.subheader(f"🏢 {agent['AgentName']}") st.write(f"**Office:** {agent['OfficeName']}") score_color = ( "green" if agent["Score"] >= 80 else "orange" if agent["Score"] >= 60 else "red" ) st.markdown( f"

Score: {agent['Score']:.1f}%

", unsafe_allow_html=True, ) with col2: metrics = agent["AgentMetrics"] cols = st.columns(4) cols[0].metric("Total Sales", metrics["TotalSales"]) cols[1].metric( "Avg Days on Market", f"{metrics['AvgDaysOnMarket']:.0f}" ) # Convert ratio to percentage for display ratio_pct = metrics["AvgPriceToListRatio"] * 100 cols[2].metric("Price/List Ratio", f"{ratio_pct:.1f}%") # Show AvgTransactionPrice only for buying agents if agent_type == "buying" and "AvgTransactionPrice" in metrics: cols[3].metric( "Avg Transaction", f"${metrics['AvgTransactionPrice']:,.0f}" ) st.divider()