Every judge/grade/exemplar/harvest
call — the exact prompt sent and the raw model reply, so a category
- decision can be traced to the call that made it. Newest first.
+ decision can be traced to the call that made it. Pick a topic to see its
+ calls.
@@ -272,7 +279,9 @@ async function loadLogs() {
async function loadLlm() {
try {
- const d = await api("/admin/api/llm");
+ const topic = $("#llmtopic").value;
+ const q = topic ? "?topic=" + encodeURIComponent(topic) : "";
+ const d = await api("/admin/api/llm" + q);
const rows = (d.calls || []).map((c) => `
`;
+ $("#llmcount").textContent = (d.calls || []).length;
} catch (e) { /* the next poll retries */ }
}
+$("#llmtopic").addEventListener("change", loadLlm);
// ---- keywords --------------------------------------------------------------
@@ -445,6 +456,11 @@ $("#extendCancel").addEventListener("click", () => {
async function loadTopics() {
const { topics } = await api("/admin/api/topics");
+ const sel = $("#llmtopic");
+ const keep = sel.value;
+ sel.innerHTML = '' +
+ topics.map((t) => ``).join("");
+ sel.value = keep;
const rows = topics.map(async (t) => {
const exs = await api("/admin/api/topics/" + encodeURIComponent(t.rkey) + "/exemplars")
.catch(() => ({ exemplars: [] }));
diff --git a/admin/server.py b/admin/server.py
index b01ca49..9396880 100644
--- a/admin/server.py
+++ b/admin/server.py
@@ -261,7 +261,9 @@ class Handler(BaseHTTPRequestHandler):
params = urllib.parse.parse_qs(
urllib.parse.urlparse(self.path).query)
n = _int_param(params, "n") or 100
- return self.reply(200, {"calls": store.recent_llm(max(1, min(n, 500)))})
+ topic = (params.get("topic") or [""])[0]
+ return self.reply(200, {"calls": store.recent_llm(max(1, min(n, 500)),
+ topic=topic)})
def keywords(self):
out = store.all_keywords()
diff --git a/feed/state.py b/feed/state.py
index a5bcbf9..736b207 100644
--- a/feed/state.py
+++ b/feed/state.py
@@ -29,13 +29,14 @@ MAX_TOPICS_PER_POST = int(os.environ.get("FEEDS_MAX_TOPICS", "5"))
# How many pool posts one topic-creation pass fits at a time.
TOPIC_SEED_BATCH = int(os.environ.get("FEEDS_TOPIC_SEED", "40"))
-# How many of the pool's nearest posts a pass_topic also offers the judge,
-# beyond the embedding region — so a brand-new topic (whose keywords have not
-# searched anything yet) shows its best matches from the existing pool right
-# away. This is also the ongoing refill channel: a post the pool gains via
-# another topic's keywords but that is close to this one gets judged on the
-# periodic pass.
-TOPIC_SEED_SIMILAR = int(os.environ.get("FEEDS_SEED_SIMILAR", "100"))
+# A new topic seeds from two sources, both offered to the judge: the pool's
+# posts nearest its exemplars (up to this distance, looser than the region so
+# the seed reaches — the exemplars are where realistic on-topic posts live)
+# and the concept phrase's nearest posts (TOPIC_SEED_SIMILAR, for breadth — a
+# concept phrase can sit beside other categories' content, which is why the
+# judge is the filter, not the seed).
+TOPIC_SEED_DISTANCE = float(os.environ.get("FEEDS_SEED_DISTANCE", "0.50"))
+TOPIC_SEED_SIMILAR = int(os.environ.get("FEEDS_SEED_SIMILAR", "40"))
# How many exemplar posts anchor a topic's region (feed/topics.exemplarize).
# A topic's phrase embeds like a concept; these realistic posts embed like the
diff --git a/feed/store.py b/feed/store.py
index f91b4d9..9830870 100644
--- a/feed/store.py
+++ b/feed/store.py
@@ -1290,10 +1290,13 @@ def _trim_llm() -> None:
_invalidate(_LLM)
-def recent_llm(n: int = 100) -> list[dict]:
- """The newest LLM calls, newest first, for the admin traceability view."""
+def recent_llm(n: int = 100, topic: str = "") -> list[dict]:
+ """The newest LLM calls, newest first, optionally for one topic's rkey —
+ for the admin traceability view."""
ensure()
rows = _rows(_LLM)
+ if topic:
+ rows = [r for r in rows if r.get("topic") == topic]
rows.sort(key=lambda r: r.get("id") or "", reverse=True)
return rows[:n]
diff --git a/feed/topics.py b/feed/topics.py
index 206fa13..6113876 100644
--- a/feed/topics.py
+++ b/feed/topics.py
@@ -282,12 +282,20 @@ def pass_topic(rkey: str, limit: int | None = None) -> int:
cur = by_uri.get(p["uri"])
if cur is None or p["_distance"] < cur["_distance"]:
by_uri[p["uri"]] = p
- # The similar-posts seed: the pool's nearest posts to the topic, offered to
- # the judge even when the region is empty (a new topic whose keywords have
- # searched nothing yet) so it shows its best matches right away. This is
- # also the ongoing refill channel — a post the pool gains via another
- # topic's keywords but that is close to this one is judged on the periodic
- # pass even if it never lands in the region.
+ # The exemplar seed: the pool's posts near the realistic exemplars
+ # (a looser distance than the region), so a new topic shows posts that
+ # look like on-topic posts. This is also the ongoing refill channel for
+ # pool posts near the exemplars.
+ for p in store.posts_within_exemplars(
+ [e["embedding"] for e in exs], state.TOPIC_SEED_DISTANCE,
+ pool_limit):
+ cur = by_uri.get(p["uri"])
+ if cur is None or p["_distance"] < cur["_distance"]:
+ by_uri[p["uri"]] = p
+ # The concept seed: the topic name's nearest posts, in addition to the
+ # exemplars, so a new topic also draws on what the concept phrase is close
+ # to. A concept phrase can sit beside other categories' content (e.g.
+ # "collective house building" beside degrowth) — the judge is the filter.
for p in store.similar_posts(topic["embedding"], state.TOPIC_SEED_SIMILAR):
cur = by_uri.get(p["uri"])
if cur is None or p["_distance"] < cur["_distance"]: