Serve Best CV match, Closing soon, the language flag and the deadline in the feed, and suggest an agent's languages from its CV

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-10-03 22:04:54 +02:00
1 parent 9960799b96
commit 14076e988d
5 files changed
+313 -34

No files matched your search

+60 -10
View File
@@ -16,11 +16,13 @@ from pydantic import BaseModel, Field
from app import jobs, places
from app.models import (
AFFINITY, RUNGS, TRACKS, Agent, Application, Company, FetchTerms, Gate, Limits, Prompts, Role, RoleRow,
AFFINITY, RUNGS, TRACKS, Agent, Application, Company, CvLanguage, CvLanguages, FetchTerms,
Gate, Limits, Prompts, Role, RoleRow,
HandReason, ScoredRole, Status, Subscription, Weights, company_key, levels_between,
)
from app.storage import Store
from app.web.deps import ConfigDep, StoreDep
from desk.notices import classify
from desk.tools import agent
from pipeline import Job
from pipeline.web import QueueDep
@@ -72,7 +74,7 @@ def _feed_filters(
tags: list[str] = Query(default=[]),
tag_mode: Literal["any", "all"] = "any",
agent: int | None = None,
order: Literal["score", "newest"] = "score",
order: Literal["score", "newest", "cv"] = "score",
gated: bool = False,
judged: Literal["", "liked", "unjudged", "passed"] = "",
pay: Literal["", "stated", "normalised", "stated_only"] = "",
@@ -83,13 +85,16 @@ def _feed_filters(
track: str = "",
seniority_unknown: bool = True,
pay_unknown: bool = False,
closing: bool = False,
) -> dict[str, Any]:
"""The feed's filters, as `Store.roles_page`, `count_roles` and
`role_facets` take them, read from the query of `GET /api/roles` and
`GET /api/roles/facets` alike. A place token that names nothing, a rung
outside `RUNGS` and a track outside `TRACKS` are a 422 sentence, not an
empty feed. The three seniority parameters become the levels between
them (`levels_between`), which is what the store filters on."""
them (`levels_between`), which is what the store filters on. `order=cv`
is the score order with the agent's judged roles first by `cv_score`
(`by_cv`)."""
for token in tokens:
if not places.known(token):
raise HTTPException(422, f"No place is known as {token!r}.")
@@ -110,10 +115,11 @@ def _feed_filters(
"function": function or None, "remote": remote or None, "days": days,
"hide_muted": not show_muted, "include_read": include_read, "tags": tags,
"tag_mode": tag_mode, "agent": _agent_id(store, agent),
"by_score": agent is not None and order == "score", "gated": gated,
"by_score": agent is not None and order in ("score", "cv"),
"by_cv": agent is not None and order == "cv", "gated": gated,
"judged": judged or None, "pay": pay or None, "company_keys": company_keys,
"places": tokens, "seniority": list(levels), "seniority_unknown": seniority_unknown,
"pay_unknown": pay_unknown}
"pay_unknown": pay_unknown, "closing": closing}
FeedFilters = Annotated[dict[str, Any], Depends(_feed_filters)]
@@ -145,7 +151,8 @@ def role_facets(store: StoreDep, filters: FeedFilters) -> Facets:
@router.get("/roles/{uid}")
def get_role(uid: str, store: StoreDep, agent: int | None = None) -> ScoredRole:
"""One role, open or closed, for the read page, with `agent`'s vote and
score, and the prompt that gave its fit (the default agent's when absent;
score, the prompt that gave its fit, its `judgement` against the agent's
CV and the language flag (the default agent's when absent;
None when there is no agent). `copies` lists the open copies of a kept
role (`RoleCopy`, for "Also posted"); a copy itself opens too, with
`dup_of` naming its kept role."""
@@ -224,7 +231,9 @@ def list_roles(
passed. With `order=score` (the default) the roles are the ones that
agent scored, best first, carrying `score` and `gated_reason`, a gated
one only with `gated=1`; with `order=newest` every open role, newest
first, with no score. Without `agent` the default agent's votes and
first, with no score; with `order=cv` (Best CV match) the scored roles
the agent's `judge` read come first by `cv_score`, the rest after them
by score. Without `agent` the default agent's votes and
hidden companies apply, the order is newest and there is no score; with
no agent at all, every vote is None and nothing is hidden.
@@ -233,7 +242,12 @@ def list_roles(
`tag_mode=all`, every one. `pay` keeps only roles whose `salary_state`
is stated or normalised, normalised only, or stated but not normalised
(`Store.PAY`); `pay_unknown` lets the roles that state no pay through
as well.
as well. `closing=1` keeps the roles whose `deadline` is today or in
the next four days (Closing soon).
Each row carries `deadline`, the agent's `cv_score` (None when not
judged), and `lang_flag` and `lang_note`, the posting's languages
against the agent's (`app.models.language_flag`).
`company` and `place` are substrings, kept for links from other pages.
The rail's fields are `company_keys` (repeated, exact keys) and
@@ -1189,7 +1203,10 @@ class AgentBody(BaseModel):
`intent` is the body from before an agent had prompts: without `prompts`
it is stored as one prompt named after the agent. `fetch_terms` narrow
what big boards send (`app/jobs/reach.py`); `[]` narrows nothing, and
leaving the key out keeps an existing agent's."""
leaving the key out keeps an existing agent's. `cv_text`,
`cv_languages`, `avoid_text` and `must_text` are what `judge` reads a
role against (`app/jobs/judge.py`), kept the same way when left out or
null."""
id: int | None = None
name: str = Field(min_length=1)
@@ -1199,9 +1216,40 @@ class AgentBody(BaseModel):
weights: Weights = Weights()
limits: Limits = Limits()
fetch_terms: FetchTerms | None = None
cv_text: str | None = None
cv_languages: CvLanguages | None = None
avoid_text: str | None = None
must_text: str | None = None
enabled: bool = True
class CvText(BaseModel):
cv_text: str = Field(min_length=1)
class CvLanguagesOut(BaseModel):
languages: list[CvLanguage]
@router.post("/agents/cv-languages")
def cv_languages(body: CvText, config: ConfigDep) -> CvLanguagesOut:
"""The languages a CV states, each with a level, from one model call
(`jobs.judge.suggest_languages`), for the owner to edit before saving.
Nothing is stored. 503 when no model is reachable, 502 when the call
gives no answer."""
if not body.cv_text.strip():
raise HTTPException(422, "Paste a CV first.")
if not agent.backend(config.agent):
raise HTTPException(503, "No model is reachable from here, so nothing can read the "
"languages. Set up the API key or Claude Code.")
try:
found = jobs.judge.suggest_languages(config, body.cv_text)
except agent.AgentError as exc:
raise HTTPException(502, classify(exc, backend=agent.backend(config.agent)).text) \
from exc
return CvLanguagesOut(languages=found)
@router.post("/agents")
def save_agent(body: AgentBody, store: StoreDep, queue: QueueDep) -> Agent:
"""Queues the rescore, which the page's `POST /api/score` after a save
@@ -1209,7 +1257,9 @@ def save_agent(body: AgentBody, store: StoreDep, queue: QueueDep) -> Agent:
try:
saved = store.save_agent(body.name, body.intent, body.gates, body.weights,
body.enabled, agent_id=body.id, limits=body.limits,
prompts=body.prompts, fetch_terms=body.fetch_terms)
prompts=body.prompts, fetch_terms=body.fetch_terms,
cv_text=body.cv_text, cv_languages=body.cv_languages,
avoid_text=body.avoid_text, must_text=body.must_text)
except ValueError as exc:
raise HTTPException(409, str(exc)) from exc
except KeyError: