Fetch terms narrow what big boards read with the wide reach send (WP F2)
An agent has fetch_terms (migration 23, API, a chip field in the agent
editor). The terms of a pull are the union over the enabled agents, none
when one of them has none. They go only to wide reads: a company tagged All
roles, or a reach ask_for drops as too many countries for a one host; a
board's {"terms": false} switches them off. SmartRecruiters q,
SuccessFactors q, Workday searchText, Phenom keywords, Eightfold query and
Oracle keyword declare query="one"; the runner makes one series per term
times the country series, drops the places first over MAX_SERIES, then the
terms. A term read is narrowed: it writes no ats:size, closes nothing and
prunes no per-role state, and the 10% guard holds it to its own
fingerprint. The Companies reach line counts the terms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3917b31209
commit
0fd45b333a
28 files changed
+839
-113
No files matched your search
@@ -24,6 +24,11 @@ filtered read, or one of a reader that declares `empty="suspect"`, that lists
|
||||
under a tenth of what the same read listed last time is recorded by the
|
||||
runner as a failure, not as a list to close against.
|
||||
|
||||
A read narrowed by the agents' fetch terms (`ats:narrowed:<target>`) lists
|
||||
the roles matching a word, which says nothing of the roles it did not list,
|
||||
so it closes nothing; only an unfiltered or a place-filtered complete read
|
||||
closes.
|
||||
|
||||
A search closes the same way when it listed everything that matches (see
|
||||
`plugins/search.py` for how each provider knows). One that did not closes its
|
||||
roles only once no search has seen them for `STALE_DAYS`. A board
|
||||
@@ -274,6 +279,8 @@ def close_boards(config: Config, store: Store, tally: Tally, *,
|
||||
if source == "ats":
|
||||
incomplete += 1
|
||||
continue
|
||||
if store.state.get(f"{source}:narrowed:{sub.target}", ""):
|
||||
continue
|
||||
seen_ids = json.loads(store.state.get(f"{source}:ids:{sub.target}", "[]"))
|
||||
if store.state.get(f"{source}:filtered:{sub.target}", ""):
|
||||
closed += _close_unlisted(store, source, seen_ids, sub.id)
|
||||
|
||||
+59
-10
@@ -27,6 +27,24 @@ on. Computed once per pull (`plan`) and handed to each board's batch as the
|
||||
A reach of more countries than a `one`-filter host should be asked one by
|
||||
one (the wide reach's Europe on SmartRecruiters) is dropped by `ask_for`,
|
||||
which knows the reader (`MAX_SERIES`), so such a board is read whole.
|
||||
|
||||
**Fetch terms** (`Agent.fetch_terms`) narrow a wide read by words, so a big
|
||||
board sends the roles that match one of them rather than every role:
|
||||
|
||||
- The terms of a pull are the union over the enabled agents. An enabled
|
||||
agent with none wants every role, so then there are none.
|
||||
- They go only with the wide reach: a company tagged All roles (`wide` in
|
||||
the reach), and a board whose reach `ask_for` drops as too many countries
|
||||
for a `one` host. The narrow reach (DK, SE) already leaves at most about
|
||||
150 roles on any big board, and small, unknown and overridden boards get
|
||||
no reach at all, so none of those take terms.
|
||||
- A board's params switch them off with `{"terms": false}`.
|
||||
- Only a reader that declares `query="one"` takes them, one series a term;
|
||||
`ask_for` has the rule for terms times the reach's series.
|
||||
- A read with terms is never the whole board: it sets no `ats:size`, and
|
||||
the pull closes nothing against it (`app/jobs/pull.py`).
|
||||
- The search providers take none. Every saved search has a query of its
|
||||
own, which terms would replace; a search is a query already.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -162,16 +180,33 @@ def require_reach(agent: Agent, gaz: places.Gazetteer) -> Reach:
|
||||
return Reach(remote=True) if remote and kept is None else EVERYWHERE
|
||||
|
||||
|
||||
def fetch_terms(agents: Iterable[Agent]) -> tuple[str, ...]:
|
||||
"""The fetch terms of a pull: the union of the agents' terms, one of each
|
||||
regardless of case, sorted; none when an agent has none, or with no
|
||||
agent."""
|
||||
found: dict[str, str] = {}
|
||||
listed = False
|
||||
for agent in agents:
|
||||
listed = True
|
||||
terms = [t.strip() for t in agent.fetch_terms if t.strip()]
|
||||
if not terms:
|
||||
return ()
|
||||
for term in terms:
|
||||
found.setdefault(term.casefold(), term)
|
||||
return tuple(found[k] for k in sorted(found)) if listed else ()
|
||||
|
||||
|
||||
@dataclass
|
||||
class Plan:
|
||||
"""The reach of one pull: `base` for every board, `wide` for the boards
|
||||
of the companies in `tagged` (tagged All roles), and each board's size
|
||||
by target."""
|
||||
of the companies in `tagged` (tagged All roles), each board's size by
|
||||
target, and the fetch `terms` of the wide reads."""
|
||||
|
||||
base: Reach
|
||||
wide: Reach = EVERYWHERE
|
||||
sizes: dict[str, int] = field(default_factory=dict)
|
||||
tagged: frozenset[str] = frozenset()
|
||||
terms: tuple[str, ...] = ()
|
||||
|
||||
def why(self, sub: Subscription) -> tuple[Reach, str]:
|
||||
"""The reach `sub` is read with, and why: `override`, `small`,
|
||||
@@ -189,8 +224,17 @@ class Plan:
|
||||
return self.base, "agents"
|
||||
|
||||
def for_subscription(self, sub: Subscription) -> dict[str, Any] | None:
|
||||
"""The `reach` a board's batch hands `ask_for`; None for none."""
|
||||
return self.why(sub)[0].params()
|
||||
"""The `reach` a board's batch hands `ask_for`; None for none. With
|
||||
fetch terms, a tagged board's carries them and `wide`, and a board on
|
||||
the agents' reach carries them for `ask_for` to use if it drops the
|
||||
countries as too many (see the module docstring)."""
|
||||
found, why = self.why(sub)
|
||||
out = found.params()
|
||||
if self.terms and why in ("tag", "agents") and (sub.params or {}).get("terms") is not False:
|
||||
out = (out or {}) | {"terms": list(self.terms)}
|
||||
if why == "tag":
|
||||
out["wide"] = True
|
||||
return out
|
||||
|
||||
|
||||
def sizes(store: Store, subs: Iterable[Subscription]) -> dict[str, int]:
|
||||
@@ -204,7 +248,8 @@ def sizes(store: Store, subs: Iterable[Subscription]) -> dict[str, int]:
|
||||
kept = state.get(f"{SIZE}{sub.target}", "")
|
||||
if kept.isdigit():
|
||||
out[sub.target] = int(kept)
|
||||
elif state.get(f"ats:ok:{sub.target}") and not state.get(f"ats:filtered:{sub.target}"):
|
||||
elif (state.get(f"ats:ok:{sub.target}") and not state.get(f"ats:filtered:{sub.target}")
|
||||
and not state.get(f"ats:narrowed:{sub.target}")):
|
||||
out[sub.target] = sum(counts.get(sub.id, {}).values())
|
||||
return out
|
||||
|
||||
@@ -225,7 +270,7 @@ def plan(store: Store, subs: Iterable[Subscription] | None = None) -> Plan:
|
||||
tagged = frozenset(c.key for c in store.companies() if c.all_roles)
|
||||
# A tag never reads less than the board would untagged: the base's
|
||||
# remote, which a `require` of Europe does not name, is kept.
|
||||
return Plan(base, wide | base, sizes(store, subs), tagged)
|
||||
return Plan(base, wide | base, sizes(store, subs), tagged, fetch_terms(agents))
|
||||
|
||||
|
||||
def reaches(store: Store, subs: Iterable[Subscription]) -> Mapping[str, dict[str, Any]]:
|
||||
@@ -248,19 +293,23 @@ _SAID = {"override": "set here", "tag": "company tag"}
|
||||
def line(found: Plan, sub: Subscription) -> str:
|
||||
"""What a pull asks `sub`'s board for, once its reader has narrowed the
|
||||
reach, in a few words: "DK, SE, remote · agents", "33 countries, remote ·
|
||||
company tag", "all roles · under 300 roles", "all roles · Greenhouse
|
||||
cannot filter"."""
|
||||
company tag", "57 countries · company tag · 3 terms", "all places ·
|
||||
company tag · 3 terms", "all roles · under 300 roles", "all roles ·
|
||||
Greenhouse cannot filter"."""
|
||||
module = readers.HOSTS.get(sub.target.partition(":")[0])
|
||||
if module is None:
|
||||
return ""
|
||||
given, why = found.why(sub)
|
||||
ask = _runner.ask_for(module, sub.params, given.params())
|
||||
ask = _runner.ask_for(module, sub.params, found.for_subscription(sub))
|
||||
terms = f" · {len(ask.terms)} term{'s' if len(ask.terms) != 1 else ''}" if ask.terms else ""
|
||||
if _runner.filtered(ask):
|
||||
words = sorted(ask.countries) if len(ask.countries) <= 4 \
|
||||
else [f"{len(ask.countries)} countries"]
|
||||
if ask.remote:
|
||||
words.append("remote")
|
||||
return f"{', '.join(words)} · {_SAID.get(why, why)}"
|
||||
return f"{', '.join(words)} · {_SAID.get(why, why)}{terms}"
|
||||
if terms:
|
||||
return f"all places · {_SAID.get(why, why)}{terms}"
|
||||
if why in ("agents", "tag") and given.everywhere:
|
||||
return f"all roles · {'company tag' if why == 'tag' else _WHOLE[why]}"
|
||||
if why in ("agents", "tag") and not module.READS.filters.declared():
|
||||
|
||||
+25
-1
@@ -1141,10 +1141,33 @@ def check_prompts(prompts: list[Prompt]) -> list[Prompt]:
|
||||
Prompts = Annotated[list[Prompt], AfterValidator(check_prompts)]
|
||||
|
||||
|
||||
def fetch_terms(value: Any) -> list[str]:
|
||||
"""Fetch terms as stored and sent: a JSON list or a list, each stripped,
|
||||
empty ones dropped, one of each regardless of case, in the order given."""
|
||||
items = _json(value, "[]")
|
||||
seen: set[str] = set()
|
||||
out: list[str] = []
|
||||
for item in items if isinstance(items, list) else []:
|
||||
term = " ".join(str(item).split())
|
||||
if term and term.casefold() not in seen:
|
||||
seen.add(term.casefold())
|
||||
out.append(term)
|
||||
return out
|
||||
|
||||
|
||||
#: An agent's fetch terms, normalised by `fetch_terms`.
|
||||
FetchTerms = Annotated[list[str], BeforeValidator(fetch_terms)]
|
||||
|
||||
|
||||
class Agent(Model):
|
||||
"""A row of `agents`: a named search with its own prompts, gates, weights
|
||||
and limits. The prompts are rows of `agent_prompts`, read alongside; their
|
||||
cached vectors are columns this does not declare."""
|
||||
cached vectors are columns this does not declare.
|
||||
|
||||
`fetch_terms` are words a role must match for a big board read with the
|
||||
wide reach to send it (`app/jobs/reach.py`): the pull's terms are the
|
||||
union over the enabled agents, and an agent with none means no board is
|
||||
narrowed by words. They decide what is fetched, not what ranks."""
|
||||
|
||||
id: int
|
||||
name: str
|
||||
@@ -1152,6 +1175,7 @@ class Agent(Model):
|
||||
gates: Annotated[list[Gate], BeforeValidator(lambda v: _json(v, "[]"))] = []
|
||||
weights: Annotated[Weights, BeforeValidator(lambda v: _json(v, "{}"))] = Weights()
|
||||
limits: Annotated[Limits, BeforeValidator(lambda v: _json(v, "{}"))] = Limits()
|
||||
fetch_terms: FetchTerms = []
|
||||
enabled: bool = True
|
||||
created_at: str
|
||||
|
||||
|
||||
+27
-10
@@ -14,6 +14,10 @@
|
||||
* form's ids stay unique. Votes, liked companies and scores are the agent's,
|
||||
* so a delete takes them with it, and the confirm says so.
|
||||
*
|
||||
* The fetch terms are chips of free text, as the towns are: words that
|
||||
* narrow what big boards read with the wide reach send (app/jobs/reach.py).
|
||||
* The card says them in a line of their own, or that boards send every role.
|
||||
*
|
||||
* Every request goes through `api()` from app.js, so a failure is one toast
|
||||
* carrying the server's own sentence.
|
||||
*/
|
||||
@@ -283,6 +287,7 @@
|
||||
if (rules) div.appendChild(el("p", "agent-rules", rules));
|
||||
div.appendChild(el("p", "agent-weights", weightsLine(row)));
|
||||
div.appendChild(limitsLine(row));
|
||||
div.appendChild(termsLine(row));
|
||||
|
||||
const actions = el("div", "agent-card-actions");
|
||||
const edit = el("button", "secondary", "Edit");
|
||||
@@ -374,15 +379,15 @@
|
||||
return { node: chips.node, values: () => [...chips.list] };
|
||||
}
|
||||
|
||||
// Towns as chips of free text, added on Enter or a comma, and one chip for
|
||||
// the spellings of a town. What is typed but not added yet counts, so Save
|
||||
// does not drop it.
|
||||
function townInput(values) {
|
||||
// Words as chips of free text, added on Enter or a comma, and one chip for
|
||||
// the spellings that fold alike. What is typed but not added yet counts, so
|
||||
// Save does not drop it. Towns and fetch terms both.
|
||||
function wordInput(values, prompt) {
|
||||
const input = el("input");
|
||||
input.type = "text";
|
||||
input.spellcheck = false;
|
||||
input.placeholder = "Add a town";
|
||||
input.setAttribute("aria-label", "Add a town");
|
||||
input.placeholder = prompt;
|
||||
input.setAttribute("aria-label", prompt);
|
||||
const split = (text) => text.split(",").map((v) => v.trim()).filter(Boolean);
|
||||
const chips = chipList(values, input, { group: fold });
|
||||
const take = () => {
|
||||
@@ -402,6 +407,14 @@
|
||||
};
|
||||
}
|
||||
|
||||
// The fetch terms on a card: the words, or that big boards send every role.
|
||||
function termsLine(row) {
|
||||
const terms = row.fetch_terms || [];
|
||||
return el("p", "agent-terms", terms.length
|
||||
? `Big boards read across Europe send only roles matching ${orList(terms.map((t) => `“${t}”`))}.`
|
||||
: "Big boards send every role: no fetch terms.");
|
||||
}
|
||||
|
||||
// A prompt as a row: its name and Remove on a line, its text under them.
|
||||
function promptRow(prompt, remove) {
|
||||
const row = el("div", "prompt-row");
|
||||
@@ -547,7 +560,9 @@
|
||||
|
||||
const { where, rest } = distribute(row ? row.gates : []);
|
||||
const countries = countryInput(where.countries ? where.countries.values : []);
|
||||
const places = townInput(where.places ? where.places.values : []);
|
||||
const places = wordInput(where.places ? where.places.values : [], "Add a town");
|
||||
const terms = wordInput(row ? row.fetch_terms || [] : [], "Add a word");
|
||||
$("#a-terms", f).replaceWith(terms.node);
|
||||
$("#a-countries", f).replaceWith(countries.node);
|
||||
$("#a-towns", f).replaceWith(places.node);
|
||||
const remote = $("#a-remote", f);
|
||||
@@ -623,7 +638,7 @@
|
||||
$("#a-delete", f).hidden = !row;
|
||||
f.addEventListener("input", () => { f.dataset.dirty = "true"; view(); });
|
||||
f.addEventListener("change", view);
|
||||
f.addEventListener("submit", (event) => save(event, row, () => prompts.map((p) => p.read()), gates));
|
||||
f.addEventListener("submit", (event) => save(event, row, () => prompts.map((p) => p.read()), gates, terms.values));
|
||||
$("#a-cancel", f).addEventListener("click", () => { close(); render(); });
|
||||
$("#a-delete", f).addEventListener("click", () => row && removeAgent(row));
|
||||
div.appendChild(f);
|
||||
@@ -669,9 +684,10 @@
|
||||
: "No search agents yet. New agent describes one.";
|
||||
}
|
||||
|
||||
// `readPrompts` and `readGates` are the form's rows as the API takes them.
|
||||
// `readPrompts`, `readGates` and `readTerms` are the form's rows and chips
|
||||
// as the API takes them.
|
||||
// A prompt with neither name nor text is an empty row, left out.
|
||||
async function save(event, row, readPrompts, readGates) {
|
||||
async function save(event, row, readPrompts, readGates, readTerms) {
|
||||
event.preventDefault();
|
||||
const f = event.target;
|
||||
const prompts = readPrompts().filter((p) => p.name || p.text.trim());
|
||||
@@ -696,6 +712,7 @@
|
||||
summarise_top: Number($("#a-summarise-top", f).value),
|
||||
summarise_min: Number($("#a-summarise-min", f).value),
|
||||
},
|
||||
fetch_terms: readTerms(),
|
||||
// Saving an agent means it is wanted, so a new one starts on; the
|
||||
// card's switch is where an existing one is switched.
|
||||
enabled: row ? row.enabled : true,
|
||||
|
||||
+3
-2
@@ -1149,7 +1149,7 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
.agent-prompt-name { margin: .7rem 0 0; font-size: .8rem; font-weight: 600; color: var(--dim); }
|
||||
.agent-prompt-name + .agent-intent { margin-top: .2rem; }
|
||||
.agent-rules { margin: 0 0 .3rem; font-size: .9rem; color: var(--dim); overflow-wrap: anywhere; }
|
||||
.agent-weights, .agent-limits { margin: 0; font-size: .8rem; color: var(--faint); font-variant-numeric: tabular-nums; }
|
||||
.agent-weights, .agent-limits, .agent-terms { margin: 0; font-size: .8rem; color: var(--faint); font-variant-numeric: tabular-nums; }
|
||||
.agent-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .8rem; }
|
||||
.agent-card-actions a { font-size: .9rem; font-weight: 600; text-decoration: none; }
|
||||
@media (hover: hover) {
|
||||
@@ -1223,7 +1223,8 @@ table.applications td[data-label="Saved"] { white-space: nowrap; color: var(--di
|
||||
border-radius: .3rem; padding: .35rem .5rem;
|
||||
}
|
||||
/* The fieldsets that hold rows: a column, the Add button under the rows. */
|
||||
.agent-form fieldset.prompts, .agent-form fieldset.where, .agent-form fieldset.rules {
|
||||
.agent-form fieldset.prompts, .agent-form fieldset.where, .agent-form fieldset.terms,
|
||||
.agent-form fieldset.rules {
|
||||
display: flex; flex-direction: column; align-items: stretch; gap: .5rem; min-width: 0;
|
||||
border: 1px solid var(--line); border-radius: .3rem;
|
||||
}
|
||||
|
||||
+17
-2
@@ -295,7 +295,9 @@ END;
|
||||
-- A search agent: a named saved search with its own prompts, gates and
|
||||
-- weights. gates is a list of {field, values, mode: require|prefer, weight}.
|
||||
-- limits is how deep into this agent's ranking extract and summarise read,
|
||||
-- as JSON: a key it lacks means the `Limits` default.
|
||||
-- as JSON: a key it lacks means the `Limits` default. fetch_terms is a JSON
|
||||
-- list of words that narrow what big boards send (app/jobs/reach.py); empty
|
||||
-- means no narrowing.
|
||||
CREATE TABLE IF NOT EXISTS agents (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
@@ -303,7 +305,8 @@ CREATE TABLE IF NOT EXISTS agents (
|
||||
weights TEXT NOT NULL DEFAULT '{}',
|
||||
enabled INTEGER NOT NULL DEFAULT 1,
|
||||
created_at TEXT NOT NULL,
|
||||
limits TEXT NOT NULL DEFAULT '{}'
|
||||
limits TEXT NOT NULL DEFAULT '{}',
|
||||
fetch_terms TEXT NOT NULL DEFAULT '[]'
|
||||
);
|
||||
|
||||
-- What an agent looks for, as several named texts in order; a role's fit is
|
||||
@@ -598,6 +601,9 @@ ALTER TABLE companies ADD COLUMN hand_reason TEXT NOT NULL DEFAULT '';
|
||||
# A Python step: the host words are read out of raw's JSON.
|
||||
(22, "roles.*_host, roles.employment, roles.prep_due and unmapped: the host's own "
|
||||
"words are stored and app.prep maps them", lambda conn: _add_host_words(conn)),
|
||||
# A Python step: it adds the column only where it is missing.
|
||||
(23, "agents.fetch_terms: words that narrow what big boards read with the wide reach "
|
||||
"send", lambda conn: _add_fetch_terms(conn)),
|
||||
)
|
||||
|
||||
#: What a file created from `SCHEMA` today is already at.
|
||||
@@ -830,6 +836,15 @@ def _add_company_aliases(conn: sqlite3.Connection) -> None:
|
||||
log.info("migration 20: %d companies folded, %d folds shared", len(rows), len(clashes))
|
||||
|
||||
|
||||
def _add_fetch_terms(conn: sqlite3.Connection) -> None:
|
||||
"""Migration 23's step: `agents.fetch_terms`, empty for every agent, so
|
||||
no board is narrowed by words until an agent is given some. Runs twice
|
||||
without harm."""
|
||||
columns = {r[1] for r in conn.execute("PRAGMA table_info(agents)")}
|
||||
if "fetch_terms" not in columns:
|
||||
conn.execute("ALTER TABLE agents ADD COLUMN fetch_terms TEXT NOT NULL DEFAULT '[]'")
|
||||
|
||||
|
||||
def _add_all_roles(conn: sqlite3.Connection) -> None:
|
||||
"""Migration 21's step. The column; the tag for every company that is a
|
||||
favourite of any agent, since favourite no longer widens what a pull
|
||||
|
||||
+13
-6
@@ -26,7 +26,7 @@ from app.models import (
|
||||
ApplicationEvent, Candidate, Company, Gate, Limits, Prompt, Role, RoleCopy, RolePlace,
|
||||
RoleRow, ScoredRole,
|
||||
Subscription, Weights, check_prompts, company_fold, company_key, country_of, excerpt, place_key,
|
||||
host_word, posted_at, posted_host, remote_of, title_key,
|
||||
fetch_terms as normal_terms, host_word, posted_at, posted_host, remote_of, title_key,
|
||||
)
|
||||
from app.storage import gazetteer, schema
|
||||
|
||||
@@ -1712,10 +1712,13 @@ class Store:
|
||||
def save_agent(self, name: str, intent: str = "", gates: Sequence[Gate] = (),
|
||||
weights: Weights | None = None, enabled: bool = True,
|
||||
agent_id: int | None = None, limits: Limits | None = None,
|
||||
prompts: Sequence[Prompt] | None = None) -> Agent:
|
||||
prompts: Sequence[Prompt] | None = None,
|
||||
fetch_terms: Sequence[str] | None = None) -> Agent:
|
||||
"""Create an agent, or with `agent_id` replace that one's fields and
|
||||
prompts. Without `prompts`, a non-empty `intent` is its one prompt,
|
||||
named after the agent. A prompt whose text is unchanged keeps its
|
||||
named after the agent. Without `fetch_terms` an update keeps the
|
||||
stored ones and a new agent has none, so a caller that does not know
|
||||
them (the CLI's prompt edit) loses none. A prompt whose text is unchanged keeps its
|
||||
cached vector, whatever its name or place, so an edit re-embeds only
|
||||
the prompts it changed. Raises ValueError on an empty or taken name,
|
||||
or two prompts of one name, KeyError on an unknown id."""
|
||||
@@ -1725,18 +1728,22 @@ class Store:
|
||||
if prompts is None:
|
||||
prompts = [Prompt(name=name, text=intent)] if intent.strip() else []
|
||||
prompts = check_prompts(list(prompts))
|
||||
terms = None if fetch_terms is None else json.dumps(
|
||||
normal_terms(list(fetch_terms)), ensure_ascii=False)
|
||||
fields = (name, json.dumps([g.model_dump() for g in gates]),
|
||||
(weights or Weights()).model_dump_json(),
|
||||
(limits or Limits()).model_dump_json(), int(enabled))
|
||||
(limits or Limits()).model_dump_json(), int(enabled), terms)
|
||||
try:
|
||||
with self.transaction() as conn:
|
||||
if agent_id is None:
|
||||
agent_id = conn.execute(
|
||||
"""INSERT INTO agents (name, gates, weights, limits, enabled,
|
||||
created_at) VALUES (?,?,?,?,?,?)""",
|
||||
fetch_terms, created_at)
|
||||
VALUES (?,?,?,?,?,COALESCE(?, '[]'),?)""",
|
||||
(*fields, self.now())).lastrowid
|
||||
elif not conn.execute(
|
||||
"""UPDATE agents SET name=?, gates=?, weights=?, limits=?, enabled=?
|
||||
"""UPDATE agents SET name=?, gates=?, weights=?, limits=?, enabled=?,
|
||||
fetch_terms=COALESCE(?, fetch_terms)
|
||||
WHERE id=?""",
|
||||
(*fields, agent_id)).rowcount:
|
||||
raise KeyError(agent_id)
|
||||
|
||||
@@ -49,6 +49,14 @@
|
||||
<span class="hint">This one ranks rather than filters: a hybrid role gains a little.</span>
|
||||
<p id="a-where-sum" class="where-sum" role="status"></p>
|
||||
</fieldset>
|
||||
<fieldset class="terms">
|
||||
<legend>What big boards send</legend>
|
||||
<div class="where-line">
|
||||
<span>Only roles matching</span>
|
||||
<div id="a-terms"></div>
|
||||
</div>
|
||||
<span class="hint">Fetch terms narrow what a big board sends when it is read across Europe: a company tagged All roles, or a host that cannot ask for each country. The board then lists only roles whose text has one of these words, one request per word. Empty means no narrowing, and while any agent that is on has none, no board is narrowed. Boards read for Denmark or Sweden, and boards under 300 roles, are never narrowed. The words decide what is fetched, not how it ranks.</span>
|
||||
</fieldset>
|
||||
<fieldset class="weights">
|
||||
<legend>How much each counts</legend>
|
||||
<label>Fit to the text <input type="number" id="a-fit" min="0" step="0.05" value="0.6"></label>
|
||||
|
||||
+6
-3
@@ -16,7 +16,7 @@ from pydantic import BaseModel, Field
|
||||
|
||||
from app import jobs, places
|
||||
from app.models import (
|
||||
AFFINITY, LEVELS, Agent, Application, Company, Gate, Limits, Prompts, Role, RoleRow,
|
||||
AFFINITY, LEVELS, Agent, Application, Company, FetchTerms, Gate, Limits, Prompts, Role, RoleRow,
|
||||
HandReason, ScoredRole, Status, Subscription, Weights, company_key,
|
||||
)
|
||||
from app.storage import Store
|
||||
@@ -1064,7 +1064,9 @@ def list_agents(store: StoreDep) -> list[Agent]:
|
||||
class AgentBody(BaseModel):
|
||||
"""Create when `id` is missing, replace that agent's fields when given.
|
||||
`intent` is the body from before an agent had prompts: without `prompts`
|
||||
it is stored as one prompt named after the agent."""
|
||||
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."""
|
||||
|
||||
id: int | None = None
|
||||
name: str = Field(min_length=1)
|
||||
@@ -1073,6 +1075,7 @@ class AgentBody(BaseModel):
|
||||
gates: list[Gate] = []
|
||||
weights: Weights = Weights()
|
||||
limits: Limits = Limits()
|
||||
fetch_terms: FetchTerms | None = None
|
||||
enabled: bool = True
|
||||
|
||||
|
||||
@@ -1083,7 +1086,7 @@ 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)
|
||||
prompts=body.prompts, fetch_terms=body.fetch_terms)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(409, str(exc)) from exc
|
||||
except KeyError:
|
||||
|
||||
Reference in new issue
Block a user