Switch the extract and summarise stages on the page, over config.yaml
A stored `stage:extract` / `stage:summarise` in the state table overrides extract.enabled / summarise.enabled; with none, the file applies. One function, stages.stage_on, decides, and both tasks' finders ask it. GET/PUT /api/stages and `app stages` show and set it with who would answer; Runs has a "What the model reads" block, and a search agent's card says when a stage is off and links to the switch. Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
1 parent
a629eda8de
commit
471ace703c
15 files changed
+593
-23
No files matched your search
+83
-1
@@ -1,4 +1,9 @@
|
||||
/* The Runs section of Sources: the "Run the pull now" button.
|
||||
/* The Runs section of Sources: the "Run the pull now" button, and the
|
||||
* switches for the two stages that ask a model.
|
||||
*
|
||||
* The switches are `/api/stages`: one row per stage, drawn as the search
|
||||
* rows above are (`.srow`, `.switch`), and a switch is a PUT that stores the
|
||||
* setting and starts nothing.
|
||||
*
|
||||
* What the queue is doing and when it runs next are `<desk-jobs>`' and
|
||||
* `<desk-schedules>`' business, and they draw themselves. The single stages
|
||||
@@ -52,11 +57,88 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------------------------------- what the model reads
|
||||
|
||||
const DOES = {
|
||||
extract: "fills in country, seniority, salary and the like from what the posting says",
|
||||
summarise: "writes a short summary and tags for the best roles",
|
||||
};
|
||||
|
||||
const el = (tag, className, text) => {
|
||||
const node = document.createElement(tag);
|
||||
if (className) node.className = className;
|
||||
if (text !== undefined) node.textContent = text;
|
||||
return node;
|
||||
};
|
||||
|
||||
/** The On/Off switch of a search agent's card, on a stage. */
|
||||
function stageSwitch(stage, rerender) {
|
||||
const label = el("label", "switch");
|
||||
const box = el("input");
|
||||
box.type = "checkbox";
|
||||
box.setAttribute("role", "switch");
|
||||
box.checked = stage.on;
|
||||
box.setAttribute("aria-label", `Run ${stage.name} in the pull`);
|
||||
const track = el("span", "switch-track");
|
||||
track.setAttribute("aria-hidden", "true");
|
||||
label.append(box, track, el("span", "switch-label", stage.on ? "On" : "Off"));
|
||||
box.addEventListener("change", async () => {
|
||||
box.disabled = true;
|
||||
try {
|
||||
Object.assign(stage, await window.api(`/api/stages/${stage.name}`,
|
||||
{ method: "PUT", body: { on: box.checked } }));
|
||||
} catch (err) {
|
||||
box.checked = !box.checked;
|
||||
box.disabled = false;
|
||||
return;
|
||||
}
|
||||
rerender();
|
||||
});
|
||||
return label;
|
||||
}
|
||||
|
||||
function renderStages(stages) {
|
||||
const list = document.getElementById("stages-list");
|
||||
list.replaceChildren();
|
||||
for (const stage of stages) {
|
||||
const row = el("div", "srow");
|
||||
if (!stage.on) row.dataset.muted = "true";
|
||||
const name = el("span", "name");
|
||||
name.append(el("span", "", stage.name[0].toUpperCase() + stage.name.slice(1)),
|
||||
el("span", "badge", stage.model));
|
||||
row.append(name, stageSwitch(stage, () => renderStages(stages)));
|
||||
const sub = el("span", "sub");
|
||||
sub.append(`${DOES[stage.name]}. How deep it reads is set per search agent, under `);
|
||||
const agents = el("a", "", "Search agents");
|
||||
agents.href = "/settings/agents";
|
||||
sub.append(agents, stage.source === "config"
|
||||
? ". Following config.yaml until this switch is used."
|
||||
: ".");
|
||||
row.appendChild(sub);
|
||||
list.appendChild(row);
|
||||
}
|
||||
const first = stages[0];
|
||||
document.getElementById("stages-answer").textContent = first
|
||||
? first.answer[0].toUpperCase() + first.answer.slice(1) + "."
|
||||
+ (first.backend ? "" : " The switches still work, and a pull passes these stages until a model is reachable.")
|
||||
: "";
|
||||
}
|
||||
|
||||
async function loadStages() {
|
||||
if (!document.getElementById("stages-list")) return;
|
||||
try {
|
||||
renderStages(await window.api("/api/stages"));
|
||||
} catch (err) {
|
||||
/* already toasted */
|
||||
}
|
||||
}
|
||||
|
||||
function update(state) {
|
||||
pulling = (state.cascades || []).some((c) => isPull(c) && live(c));
|
||||
paint();
|
||||
}
|
||||
|
||||
loadStages();
|
||||
document.addEventListener("app:jobs", (e) => update(e.detail || {}));
|
||||
// A snapshot that arrived before this script loaded.
|
||||
if (window.live && window.live.jobs) update(window.live.jobs);
|
||||
|
||||
Reference in new issue
Block a user