-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
281 lines (246 loc) · 10.1 KB
/
streamlit_app.py
File metadata and controls
281 lines (246 loc) · 10.1 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import streamlit as st
import requests
from streamlit_lottie import st_lottie
import json
# Config
st.set_page_config(
page_title="SHL Assessment Recommender Pro",
layout="wide",
page_icon="🎯",
initial_sidebar_state="expanded"
)
# Custom CSS for basic styling
st.markdown("""
<style>
.assessment-card {
border-radius: 8px;
padding: 1.5rem;
margin-bottom: 1.5rem;
background: #2d3a3a;
box-shadow: 0 2px 12px rgba(0,0,0,0.1);
border-left: 4px solid #4CAF50;
}
.relevance-badge {
background: #1e3a1e;
color: #8bc34a;
padding: 0.25rem 0.75rem;
border-radius: 12px;
font-weight: 600;
}
.ai-insights {
background: #2a3535;
padding: 1rem;
border-radius: 6px;
margin-top: 1rem;
border-left: 3px solid #607d8b;
}
.detail-container {
display: flex;
margin: 0.5rem 0;
}
.detail-label {
font-weight: 600;
color: #a8c7cb;
min-width: 120px;
}
.detail-value {
color: #ffffff;
}
.instruction-card {
background: #1e2a2a;
border-radius: 8px;
padding: 1.5rem;
margin-bottom: 1.5rem;
border-left: 4px solid #2196F3;
}
.example-box {
background: #252f2f;
padding: 0.75rem;
border-radius: 6px;
margin: 0.5rem 0;
font-family: 'Courier New', monospace;
border-left: 3px solid #4CAF50;
}
.tip-box {
background: #2a2520;
padding: 0.75rem;
border-radius: 6px;
margin: 0.5rem 0;
border-left: 3px solid #FF9800;
}
</style>
""", unsafe_allow_html=True)
# Header
st.title("🎯 SHL Assessment Recommender")
st.caption("Intelligent matching for talent acquisition professionals")
# Add Instructions Section at the top
with st.expander("📖 How to Use This Application", expanded=False):
st.markdown("""
<div class="instruction-card">
<h3>🚀 Getting Started</h3>
<p>This AI-powered tool helps you find the most relevant SHL assessments for your hiring needs. Simply describe the role or paste a job description URL, and get instant recommendations.</p>
</div>
""", unsafe_allow_html=True)
col1, col2 = st.columns(2)
with col1:
st.markdown("### 💡 Input Methods")
st.markdown("""
<div class="tip-box">
<strong>Method 1: Text Description</strong><br>
Describe the role in your own words with key details like:
<ul>
<li>Job title and level (entry, mid, senior)</li>
<li>Key skills required</li>
<li>Industry or domain</li>
<li>Specific competencies needed</li>
</ul>
</div>
""", unsafe_allow_html=True)
st.markdown("""
<div class="tip-box">
<strong>Method 2: Job Description URL</strong><br>
Paste a direct link to any job posting, and the system will automatically extract and analyze the requirements.
</div>
""", unsafe_allow_html=True)
with col2:
st.markdown("### ✨ Example Prompts")
st.markdown("""
<div class="example-box">
<strong>Example 1:</strong><br>
"Senior software engineer with 5+ years experience in Python and cloud technologies"
</div>
""", unsafe_allow_html=True)
st.markdown("""
<div class="example-box">
<strong>Example 2:</strong><br>
"Entry-level customer service representative with strong communication skills"
</div>
""", unsafe_allow_html=True)
st.markdown("""
<div class="example-box">
<strong>Example 3:</strong><br>
"Financial analyst position requiring analytical thinking and Excel proficiency"
</div>
""", unsafe_allow_html=True)
st.markdown("---")
st.markdown("### 🎯 Best Practices for Optimal Results")
tips_col1, tips_col2, tips_col3 = st.columns(3)
with tips_col1:
st.markdown("""
**Be Specific**
- Include job level (junior/mid/senior)
- Mention key skills or competencies
- Add industry context if relevant
""")
with tips_col2:
st.markdown("""
**Keep It Clear**
- Use natural language
- Focus on core requirements
- Avoid overly complex jargon
""")
with tips_col3:
st.markdown("""
**Enable AI Insights**
- Toggle AI insights for detailed analysis
- Get personalized recommendations
- Understand assessment fit better
""")
st.markdown("---")
st.markdown("### 📊 Understanding Results")
st.markdown("""
- **Relevance Score**: Ranges from 0.0 (perfect match) to 1.0 (less relevant). Lower scores indicate better matches.
- **AI Insights**: When enabled, provides expert analysis on key skills measured, ideal candidate level, and best use cases.
- **Assessment Details**: Includes duration, language support, job level suitability, and testing format options.
""")
# Sidebar
with st.sidebar:
st.header("⚙️ Configuration")
use_ai = st.toggle("Enable AI Insights", value=True)
with st.expander("🔧 Advanced Settings"):
api_url = st.text_input(
"API Endpoint",
value="https://talentlens-gdmn.onrender.com/recommend",
)
st.markdown("---")
st.markdown("""
**📊 Interpretation Guide**
- **Relevance Score**: Lower is better (0.0 = perfect match)
- **Support Icons**:
- 🟢 = Supported
- 🔴 = Not Supported
- ❓ = Unknown
""")
# Main Content
query = st.text_input(
"🔍 Describe the role:",
placeholder="e.g. 'Mid-level account manager with client experience'"
)
if st.button("Find Assessments", type="primary") and query:
with st.spinner("🔍 Finding optimal assessments..."):
try:
response = requests.post(
api_url,
json={"text": query, "use_ai": use_ai},
timeout=120
).json()
if not response:
st.warning("No assessments found. Try different keywords.")
else:
st.success(f"🎉 Found {len(response)} matching assessments")
for item in sorted(response, key=lambda x: x['score']):
# Safely handle all fields with defaults
name = item.get('name', 'Unknown Assessment')
url = item.get('url', '#')
score = item.get('score', 1.0)
duration = item.get('duration', 'Not specified')
languages = ''.join(item.get('languages', [])) or 'Not specified'
job_level = item.get('job_level', 'Not specified')
remote_testing = item.get('remote_testing', '❓')
adaptive_support = item.get('adaptive_support', item.get('adaptive/irt_support', '❓'))
test_type = item.get('test_type', 'Not specified')
description = item.get('description', 'No description available')
ai_insights = item.get('ai_insights', '') if use_ai else ''
# Create assessment card using Streamlit components
with st.container():
st.markdown('<div class="assessment-card">', unsafe_allow_html=True)
# Header row
col1, col2 = st.columns([4, 1])
with col1:
st.subheader(name)
with col2:
st.markdown(f'<span class="relevance-badge">Relevance: {score:.3f}</span>',
unsafe_allow_html=True)
# Details using columns for layout
def detail_row(label, value):
cols = st.columns([1, 3])
with cols[0]:
st.markdown(f'<div class="detail-label">{label}</div>', unsafe_allow_html=True)
with cols[1]:
st.markdown(f'<div class="detail-value">{value}</div>', unsafe_allow_html=True)
detail_row("🔗 URL:", f'<a href="{url}" target="_blank">View Assessment</a>')
detail_row("⏱ Duration:", duration)
detail_row("🗣 Languages:", languages)
detail_row("📊 Job Level:", job_level)
detail_row("🏠 Remote Testing:", f'<span class="support-icon">{remote_testing}</span>')
detail_row("🔄 Adaptive/IRT:", f'<span class="support-icon">{adaptive_support}</span>')
detail_row("🧪 Test Type:", test_type)
# Description
st.markdown("---")
st.markdown("**Description:**")
st.markdown(description)
# AI Insights
if ai_insights:
st.markdown('<div class="ai-insights">', unsafe_allow_html=True)
st.markdown("**🤖 AI Analysis:**")
for line in ai_insights.split('\n'):
if line.strip():
st.markdown(f"• {line.strip()}")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
except Exception as e:
st.error(f"⚠️ Error: {str(e)}")
st.info("Please ensure the API is running at the specified endpoint")
# Footer
st.markdown("---")
st.caption("SHL Assessment Recommender | Professional Edition")