Ask extract where a remote hire may live and map its answer before the rescore
remote_where is a list of names, [] when not stated. Remote is remote with a regular office week and hybrid with set office days each week. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e4c0de4465
commit
6f2b1ff72a
2 files changed
+42
-8
No files matched your search
+40
-7
@@ -7,9 +7,11 @@ Sharing the backlog out a call at a time, the give-up count, splitting a
|
||||
refused batch, and failing with a notice when no model is reachable are
|
||||
`desk.modeltask`'s.
|
||||
|
||||
`extract` is also the afterburner for the level. A role is waiting while it is
|
||||
open, has not been given up on, has never been answered (`extracted_at IS
|
||||
NULL`) or has no model level (`seniority_model` empty), and is in the best of an enabled agent's
|
||||
`extract` is also the afterburner for the level and the remote area. A role
|
||||
is waiting while it is open, has not been given up on, has never been
|
||||
answered (`extracted_at IS NULL`), has no model level (`seniority_model`
|
||||
empty) or was never asked where a remote hire may live (`remote_where_model`
|
||||
NULL), and is in the best of an enabled agent's
|
||||
ungated scores as deep and as low as that agent's own `limits` say
|
||||
(`extract_top`, `extract_min`). That bound is what keeps the cost
|
||||
proportional to the rankings rather than to the boards:
|
||||
@@ -20,7 +22,10 @@ fills columns that are still empty: a board's structured field wins over what
|
||||
a model read out of the prose. The exception is the level, which the model
|
||||
always gives (the board's word and the title's go in as hints) and which
|
||||
overrules them; both stay in `seniority_stated` and `seniority_title`, so
|
||||
`Store.seniority_agreement` can compare them. See `Store.set_extracted`.
|
||||
`Store.seniority_agreement` can compare them. Remote is the other: the
|
||||
model's `remote` and `remote_where` are kept as they come, and prep composes
|
||||
the role's `remote` (the model's first) and its area from them
|
||||
(`prep.run_roles`) before the rescore reads them. See `Store.set_extracted`.
|
||||
|
||||
Off by default (`extract.enabled: false`), because on the API backend every
|
||||
batch is a paid call. Whether it runs is `stages.stage_on`: the switch under
|
||||
@@ -39,6 +44,7 @@ from typing import Any
|
||||
from desk import modeltask
|
||||
from desk.modeltask import ModelTask
|
||||
from pipeline import NULL, RunContext, Task, job
|
||||
from app import prep
|
||||
from app.config import Config
|
||||
from app.jobs import stages
|
||||
from app.models import LEVELS, PERMITS, REMOTE, SENIORITIES, ExtractResult, Role
|
||||
@@ -72,6 +78,15 @@ Fields:
|
||||
("Berlin", "Greater London"). '' if none is named.
|
||||
- country: ISO 3166-1 alpha-2 code of that place ("DE", "GB"), or ''.
|
||||
- remote: "remote", "hybrid" or "onsite" only when the posting says so, else ''.
|
||||
"remote" when the hire works from home most of the time, even with a
|
||||
regular office week (one week a month, a few days a quarter); "hybrid" when
|
||||
there are set office days every week; "onsite" when the work is at the
|
||||
office or the site.
|
||||
- remote_where: where a remote hire may live, as the posting states it: the
|
||||
countries, regions or continents by their English names (["Denmark"],
|
||||
["Europe"], ["United States", "Canada"]), or ["anywhere"] for worldwide.
|
||||
An office location is not this, only where the hire may work from. [] when
|
||||
the role is not remote or the posting does not say.
|
||||
- seniority: exactly one of {", ".join(LEVELS)}, for every posting; never ''.
|
||||
This is the one field where you decide rather than extract. The levels are
|
||||
one ladder; from staff up each rung has an individual-contributor level and
|
||||
@@ -119,6 +134,7 @@ SCHEMA: dict[str, Any] = {
|
||||
"place": _TEXT,
|
||||
"country": _TEXT,
|
||||
"remote": {"type": "string", "enum": list(REMOTE)},
|
||||
"remote_where": {"type": "array", "items": _TEXT},
|
||||
"seniority": {"type": "string", "enum": list(LEVELS)},
|
||||
"salary_min": _SALARY,
|
||||
"salary_max": _SALARY,
|
||||
@@ -127,7 +143,7 @@ SCHEMA: dict[str, Any] = {
|
||||
"permit": {"type": "string", "enum": list(PERMITS)},
|
||||
"languages_required": {"type": "array", "items": _TEXT},
|
||||
},
|
||||
"required": ["uid", "place", "country", "remote", "seniority",
|
||||
"required": ["uid", "place", "country", "remote", "remote_where", "seniority",
|
||||
"salary_min", "salary_max", "currency", "function",
|
||||
"permit", "languages_required"],
|
||||
"additionalProperties": False,
|
||||
@@ -186,15 +202,28 @@ def _salary(value: Any) -> int | None:
|
||||
return int(value) if value > 0 else None
|
||||
|
||||
|
||||
#: How many names `remote_where` keeps, and how long each may be.
|
||||
_WHERE_NAMES, _WHERE_LEN = 12, 60
|
||||
|
||||
|
||||
def _names(value: Any) -> list[str]:
|
||||
"""`remote_where` checked: strings, whitespace collapsed, each once."""
|
||||
found = [" ".join(str(name).split())[:_WHERE_LEN]
|
||||
for name in (value if isinstance(value, list) else [])]
|
||||
return list(dict.fromkeys(name for name in found if name))[:_WHERE_NAMES]
|
||||
|
||||
|
||||
def fields(answer: dict[str, Any]) -> dict[str, Any]:
|
||||
"""One answer, checked field by field. Anything outside a field's
|
||||
vocabulary is '' or None, which `set_extracted` never writes."""
|
||||
vocabulary is '' or None, which `set_extracted` never writes, except
|
||||
for `remote` and `remote_where`, which it writes as they come."""
|
||||
languages = [code for raw in answer.get("languages_required") or []
|
||||
if (code := _code(raw, _LANGUAGE, upper=False))]
|
||||
return {
|
||||
"place": " ".join(str(answer.get("place") or "").split())[:200],
|
||||
"country": _code(answer.get("country"), _COUNTRY, upper=True),
|
||||
"remote": _pick(answer.get("remote"), REMOTE),
|
||||
"remote_where": _names(answer.get("remote_where")),
|
||||
"seniority": _pick(answer.get("seniority"), SENIORITIES),
|
||||
"salary_min": _salary(answer.get("salary_min")),
|
||||
"salary_max": _salary(answer.get("salary_max")),
|
||||
@@ -211,8 +240,10 @@ def apply_batch(store: Store, answer: dict[str, Any],
|
||||
"""Write the answers back. A uid the batch did not carry is rejected
|
||||
rather than written, so a reply cannot reach a role it was not shown. A
|
||||
role the reply leaves out keeps `extracted_at` NULL and is charged a
|
||||
turn by `modeltask.one`."""
|
||||
turn by `modeltask.one`. The roles answered are mapped again
|
||||
(`prep.run_roles`), so their remote and area follow the model's."""
|
||||
wanted = {row["uid"] for row in (batch or {}).get("roles", [])}
|
||||
answered: list[str] = []
|
||||
stats = ExtractResult()
|
||||
for one in answer.get("roles") or []:
|
||||
uid = str(one.get("uid") or "")
|
||||
@@ -228,8 +259,10 @@ def apply_batch(store: Store, answer: dict[str, Any],
|
||||
stats.rejected.append(uid)
|
||||
continue
|
||||
wanted.discard(uid)
|
||||
answered.append(uid)
|
||||
stats.extracted += 1
|
||||
stats.filled += filled
|
||||
prep.run_roles(store, answered)
|
||||
return stats
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user