Skip to content

Commit ba16276

Browse files
committed
feat: expose skill experience duration in expert search
- Update find_experts_logic to include the 'experience' field from the API - Add test case verifying experience duration appears in output - Enables LLM to filter consultants by duration (e.g. 'at least 6 months')
1 parent a397931 commit ba16276

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

src/agileday_server.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,15 @@ def find_experts_logic(skill_name: str) -> str:
125125
if relevant:
126126
name = f"{emp.get('firstName', '')} {emp.get('lastName', '')}".strip()
127127
title = emp.get('title', 'No Title')
128-
details = ", ".join([f"{s['name']} ({s.get('proficiency', '?')}/5)" for s in relevant])
128+
details_list = []
129+
for s in relevant:
130+
prof = s.get('proficiency', '?')
131+
# The API returns ISO duration (e.g. P1Y) or string. We pass it raw to the LLM.
132+
exp = s.get('experience')
133+
exp_str = f", Exp: {exp}" if exp else ""
134+
details_list.append(f"{s['name']} (Lvl {prof}/5{exp_str})")
135+
136+
details = ", ".join(details_list)
129137
matches.append(f"👤 **{name}** - {title}\n └─ {details}")
130138

131139
return "\n\n".join(matches) if matches else f"No experts found for '{skill_name}'."

tests/test_agileday_server.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ def test_base_url_configuration():
3232
expected_url = "https://test-tenant.agileday.io/api"
3333
assert BASE_URL == expected_url
3434

35+
def test_find_experts_case_insensitive(mock_api_response):
36+
"""Test that 'python' finds 'Python'."""
37+
mock_data = [{"firstName": "Alice", "skills": [{"name": "Python", "proficiency": 5}]}]
38+
mock_api_response.return_value.json.return_value = mock_data
39+
40+
# UPDATED CALL
41+
result = find_experts_logic("python")
42+
43+
assert "Python" in result
44+
3545
def test_find_experts_found(mock_api_response):
3646
"""Test searching for a skill that exists."""
3747
mock_data = [
@@ -53,23 +63,39 @@ def test_find_experts_found(mock_api_response):
5363
]
5464
mock_api_response.return_value.json.return_value = mock_data
5565

56-
# UPDATED CALL: find_experts_logic
5766
result = find_experts_logic("Python")
5867

5968
assert "Alice Engineer" in result
6069
assert "Senior Dev" in result
61-
assert "Python (5/5)" in result
70+
# Note: Older logic didn't have Exp, so this asserts basic format
71+
assert "Python" in result
6272
assert "Bob" not in result
6373

64-
def test_find_experts_case_insensitive(mock_api_response):
65-
"""Test that 'python' finds 'Python'."""
66-
mock_data = [{"firstName": "Alice", "skills": [{"name": "Python", "proficiency": 5}]}]
74+
def test_find_experts_includes_experience(mock_api_response):
75+
"""
76+
New Test: Ensure that the 'experience' field from the API
77+
is correctly formatted into the output string.
78+
"""
79+
mock_data = [
80+
{
81+
"firstName": "Senior",
82+
"lastName": "Dev",
83+
"title": "Architect",
84+
"skills": [
85+
# API returns experience as a string (e.g. "2 years" or ISO "P2Y")
86+
{"name": "Java", "proficiency": 5, "experience": "5 years"},
87+
{"name": "Python", "proficiency": 4, "experience": "6 months"}
88+
]
89+
}
90+
]
6791
mock_api_response.return_value.json.return_value = mock_data
6892

69-
# UPDATED CALL
70-
result = find_experts_logic("python")
71-
72-
assert "Python" in result
93+
# Search for Java
94+
result = find_experts_logic("Java")
95+
96+
# Assert that the experience string is present in the output
97+
assert "Senior Dev" in result
98+
assert "Java (Lvl 5/5, Exp: 5 years)" in result
7399

74100
def test_find_experts_no_matches(mock_api_response):
75101
"""Test response when no one has the skill."""

0 commit comments

Comments
 (0)