File size: 5,499 Bytes
f0aeabd 58dc8dd f0aeabd |
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
import streamlit as st
import pandas as pd
from llm_services.agenthub import recommend_talent_agent
from llm_services.tools import recommend_talent_tool
st.set_page_config(
page_title="Talent Recommender",
page_icon="🎯",
layout="wide"
)
st.markdown("""
<style>
.profile-card {
background-color: #f8f9fa;
border-radius: 10px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.metrics-container {
display: flex;
justify-content: space-between;
margin-top: 15px;
}
.metric-item {
text-align: center;
padding: 10px;
border-radius: 5px;
background-color: #e9ecef;
}
.header-container {
padding: 1.5rem;
background: linear-gradient(90deg, #4b6cb7 0%, #182848 100%);
color: white;
border-radius: 10px;
margin-bottom: 2rem;
}
</style>
""", unsafe_allow_html=True)
st.markdown("""
<div class="header-container">
<h1 style="text-align: center;">Talent Recommender</h1>
<p style="text-align: center; font-size: 1.2rem;">Find the perfect influencer match for your brand</p>
</div>
""", unsafe_allow_html=True)
if 'search_history' not in st.session_state:
st.session_state.search_history = []
st.markdown("### What kind of talent are you looking for?")
brand_request = st.text_area(
"Describe your needs in natural language",
placeholder="e.g., We need financial advisors with high engagement to promote our investment app to professionals aged 30-50",
height=120
)
search_button = st.button("Find Talent", type="primary")
if search_button and brand_request:
if brand_request not in st.session_state.search_history:
st.session_state.search_history.append(brand_request)
with st.spinner("Finding the perfect talent matches..."):
try:
search_args = recommend_talent_agent(brand_request=brand_request)
with st.expander("Search Parameters", expanded=False):
st.json(search_args)
profiles = recommend_talent_tool(**search_args)
st.subheader(f"Top 10 K Results")
tab1, tab2 = st.tabs(["Cards View", "Table View"])
with tab1:
for i, profile in enumerate(profiles):
with st.container():
st.markdown(f"""
<div class="profile-card">
<h3>{profile['name']}</h3>
<p><strong>Age:</strong> {profile['age']} | <strong>Gender:</strong> {profile['gender']}</p>
<p><strong>Verticals:</strong> {', '.join(profile['verticals'])}</p>
<p><strong>Bio:</strong> {profile['bio']}</p>
<div class="metrics-container">
<div class="metric-item">
<p style="margin:0; font-weight:bold;">{profile['follower_count']:,}</p>
<p style="margin:0; font-size:0.8rem;">Followers</p>
</div>
<div class="metric-item">
<p style="margin:0; font-weight:bold;">{profile['overall_engagement']:.1%}</p>
<p style="margin:0; font-size:0.8rem;">Engagement</p>
</div>
</div>
</div>
""", unsafe_allow_html=True)
with tab2:
table_data = []
for profile in profiles:
table_data.append({
"Name": profile['name'],
"Age": profile['age'],
"Gender": profile['gender'],
"Verticals": ", ".join(profile['verticals']),
"Followers": profile['follower_count'],
"Engagement": f"{profile['overall_engagement']:.1%}"
})
df = pd.DataFrame(table_data)
st.dataframe(
df,
use_container_width=True,
hide_index=True
)
except Exception as e:
st.error(f"An error occurred: {str(e)}")
st.info("Please try refining your request or check your connection.")
else:
if st.session_state.search_history:
st.markdown("### Recent Searches")
for idx, search in enumerate(st.session_state.search_history[-3:]):
if st.button(f"{search}", key=f"history_{idx}"):
brand_request = search
st.experimental_rerun()
st.markdown("""
### How to use this tool:
Simply describe what kind of talent you're looking for in natural language. Our AI will analyze your request and find the most suitable matches from our database.
**Example:** "We need financial advisors with high engagement rates to promote our new investment app targeting professionals aged 35-55."
""")
st.markdown("---")
st.markdown("""
<p style="text-align: center; color: #6c757d; font-size: 0.8rem;">
Talent Recommender v1.0 | Powered by AI | © 2025
</p>
""", unsafe_allow_html=True) |