Summarise and fetch text: a summary stage after score, two role routes
app/jobs/summarise.py is a ModelTask beside extract: about 60 words per role
from title, company, place and the fetched page else the description (capped
at 8000 characters). The pull cascade gains a summarise stage after score that
takes only roles without a summary in the top summarise.per_agent of an
enabled agent's ungated scores, and finds nothing when summarise.enabled is
false or no model is reachable. A reply that leaves a role unanswered is
counted in the state table and the role is given up after three.
POST /api/roles/{uid}/text scrapes original_url once and stores
article_text; POST /api/roles/{uid}/summarise queues a summarise_batch for
that uid alone, deduped per role.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d31cca394
commit
9035529e0d
12 files changed
+733
-10
No files matched your search
@@ -312,3 +312,46 @@ def test_an_application_may_point_at_a_role(store: Store) -> None:
|
||||
saved = store.save_application(Application(role_uid=posting().uid, status="applied"))
|
||||
assert saved.role_uid == posting().uid
|
||||
assert [e.status for e in store.application_events(saved.id)] == ["applied"]
|
||||
|
||||
|
||||
# -------------------------------------------------- summary and posting text
|
||||
|
||||
def test_the_posting_text_is_stored_and_stamped(store: Store) -> None:
|
||||
store.upsert_role(posting())
|
||||
role = store.set_article_text(posting().uid, "The whole posting.")
|
||||
assert role is not None
|
||||
assert role.article_text == "The whole posting." and role.article_at == store.now()
|
||||
assert store.set_article_text("nope", "x") is None
|
||||
|
||||
|
||||
def test_a_summary_is_written_once(store: Store) -> None:
|
||||
store.upsert_role(posting())
|
||||
uid = posting().uid
|
||||
assert store.set_summary(uid, "First.") is True
|
||||
assert store.set_summary(uid, "Second.") is False
|
||||
role = store.role(uid)
|
||||
assert role is not None and role.summary == "First." and role.summarised_at
|
||||
assert store.set_summary("nope", "x") is False
|
||||
|
||||
|
||||
def test_summarise_waits_on_the_top_of_each_enabled_agent(store: Store) -> None:
|
||||
"""Two agents each contribute their own top one; a closed role, a hidden
|
||||
company's role and a gated score are not in anybody's top."""
|
||||
for sid, company in (("a", "Acme"), ("b", "Acme"), ("c", "Hidden"), ("d", "Acme")):
|
||||
store.upsert_role(posting(sid, company=company))
|
||||
a, b, c, d = (posting(s).uid for s in "abcd")
|
||||
store.add_company("Hidden", key="hidden", affinity=-1)
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET closed_at = ? WHERE uid = ?", (store.now(), d))
|
||||
one = store.save_agent("One")
|
||||
two = store.save_agent("Two")
|
||||
store.replace_scores(one.id, [(d, 0.99, ""), (a, 0.9, ""), (b, 0.5, "")])
|
||||
store.replace_scores(two.id, [(a, 0.95, "remote"), (c, 0.9, ""), (b, 0.8, "")])
|
||||
|
||||
waiting = {r.uid for r in store.summarise_waiting(10, per_agent=1)}
|
||||
|
||||
# `c` is agent two's best open ungated role but its company is hidden.
|
||||
assert waiting == {a}
|
||||
assert {r.uid for r in store.summarise_waiting(10, per_agent=2)} == {a, b}
|
||||
assert store.summarise_pending(per_agent=2) == 2
|
||||
assert [r.uid for r in store.summarise_waiting(10, 1, uids=[d])] == [d]
|
||||
Reference in new issue
Block a user