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
+17
-4
@@ -15,7 +15,8 @@ button) takes those roles whatever their rank. See `Store.summarise_waiting`.
|
||||
The text is `article_text` when the posting page was fetched, else
|
||||
`description`. A role with neither is not waiting at all, so it is never sent.
|
||||
|
||||
Off by default (`summarise.enabled: false`), like extract.
|
||||
Off by default (`summarise.enabled: false`), like extract. Whether it runs is
|
||||
`stages.stage_on`: the switch under Runs, else the config file.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -29,6 +30,7 @@ from desk.models import ModelTaskResult
|
||||
from desk.modeltask import ModelTask
|
||||
from pipeline import NULL, RunContext, Task, job
|
||||
from app.config import Config
|
||||
from app.jobs import stages
|
||||
from app.models import Role
|
||||
from app.storage import Store
|
||||
|
||||
@@ -195,8 +197,19 @@ def run_batch(config: Config, store: Store, *, context: RunContext = NULL,
|
||||
return modeltask.one(TASK, config, store, uids or [], context=context).model_dump()
|
||||
|
||||
|
||||
def _always(config: Config) -> Any:
|
||||
"""See `extract._always`."""
|
||||
return config.summarise.model_copy(update={"enabled": True})
|
||||
|
||||
|
||||
def summarise_task() -> Task:
|
||||
"""Finds nothing while `summarise.enabled` is false, so the task, `app
|
||||
job summarise` and the cascade stage are all no-ops with the switch
|
||||
"""Finds nothing while the stage is off (`stages.stage_on`), so the task,
|
||||
`app job summarise` and the cascade stage are all no-ops with the switch
|
||||
off."""
|
||||
return replace(modeltask.of(TASK), label=TASK.label)
|
||||
stage = modeltask.of(replace(TASK, settings=_always))
|
||||
find = stage.finder
|
||||
|
||||
def when_on(config: Config, store: Store) -> Any:
|
||||
return find(config, store) if stages.stage_on(config, store, "summarise") else []
|
||||
|
||||
return replace(stage, finder=when_on)
|
||||
Reference in new issue
Block a user