Make the three CV match weights a per-agent setting, applied when a role is served
cv_skills, cv_experience and cv_career live in agents.weights (30, 25, 30 by default), edited on the Search agents page beside fit and recency. cv_score is worked out at read time in the feed order, the row and the reader, so changing them asks the model for nothing and leaves the judge's input_key alone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5df707148
commit
585c332d74
8 files changed
+147
-28
No files matched your search
+45
-1
@@ -16,7 +16,8 @@ from fastapi.testclient import TestClient
|
||||
|
||||
from app.config import Config, ServerConfig
|
||||
from app.main import create_app
|
||||
from app.models import CvLanguage, Prompt
|
||||
from app.jobs.judge import input_key
|
||||
from app.models import CvLanguage, Prompt, Weights, cv_score
|
||||
from app.storage import Store
|
||||
from desk.models import Item
|
||||
from desk.tools import agent
|
||||
@@ -90,6 +91,49 @@ def test_best_cv_match_puts_the_judged_first_by_cv_score(
|
||||
"order": "best"}).status_code == 422
|
||||
|
||||
|
||||
def test_the_agents_weights_make_the_cv_score_at_read_time(
|
||||
client: TestClient, store: Store) -> None:
|
||||
owner, uid = setup(store)
|
||||
# c: skills 100, experience 0, career 0; b: 60 on all three.
|
||||
store.set_judgement(owner.id, uid["c"], "k", 100, 0, 0, ["Leads data."], ["Small team."])
|
||||
key_before = input_key(owner, "text")
|
||||
|
||||
def asked() -> tuple[list[tuple[str, float | None]], float | None]:
|
||||
rows = client.get("/api/roles", params={"agent": owner.id, "order": "cv"}).json()
|
||||
one = client.get(f"/api/roles/{uid['c']}", params={"agent": owner.id}).json()
|
||||
assert one["cv_score"] == one["judgement"]["cv_score"]
|
||||
return [(r["uid"], r["cv_score"]) for r in rows["items"]], one["cv_score"]
|
||||
|
||||
rows, one = asked()
|
||||
assert rows[:2] == [(uid["b"], 60.0), (uid["c"], round(3000 / 85, 1))] and one == 35.3
|
||||
|
||||
def weigh(**w: float) -> None:
|
||||
store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id,
|
||||
weights=Weights(**w), cv_text=owner.cv_text)
|
||||
|
||||
weigh(cv_skills=1, cv_experience=0, cv_career=0)
|
||||
rows, one = asked()
|
||||
assert rows[:2] == [(uid["c"], 100.0), (uid["b"], 60.0)] and one == 100.0
|
||||
weigh(cv_skills=0, cv_experience=0, cv_career=0)
|
||||
rows, one = asked()
|
||||
assert [c for _, c in rows] == [None, None, None] and one is None
|
||||
assert [u for u, _ in rows] == [uid["a"], uid["b"], uid["c"]], "by score, as none is judged"
|
||||
assert client.get(f"/api/roles/{uid['c']}",
|
||||
params={"agent": owner.id}).json()["judgement"]["skills"] == 100
|
||||
refreshed = store.agent(owner.id)
|
||||
assert refreshed is not None and input_key(refreshed, "text") == key_before, \
|
||||
"the weights are no part of what the judge read"
|
||||
|
||||
|
||||
def test_the_weights_are_per_agent_json_with_the_old_values_as_default(store: Store) -> None:
|
||||
owner = store.save_agent("Data", prompts=[Prompt(name="Lead", text="Head of data")])
|
||||
assert (owner.weights.cv_skills, owner.weights.cv_experience,
|
||||
owner.weights.cv_career) == (30, 25, 30)
|
||||
assert cv_score(80, 60, 40, owner.weights) == round((2400 + 1500 + 1200) / 85, 1)
|
||||
assert cv_score(80, 60, 40, Weights(cv_skills=0, cv_experience=1, cv_career=1)) == 50.0
|
||||
assert cv_score(80, 60, 40, Weights(cv_skills=0, cv_experience=0, cv_career=0)) is None
|
||||
|
||||
|
||||
def test_a_row_carries_the_deadline_and_the_language_flag(
|
||||
client: TestClient, store: Store) -> None:
|
||||
owner, uid = setup(store)
|
||||
|
||||
Reference in new issue
Block a user