Anas989898's picture
added
58dc8dd
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)