Embed a role again when its text arrives, and keep the place its own page gave
A role listed before its page was read kept a title-only vector, and the listing's place replaced the page's on every later pull. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
fd89381caa
commit
31abad4c8e
5 files changed
+69
-6
No files matched your search
@@ -415,12 +415,18 @@ class Store:
|
||||
columns = ", ".join(row)
|
||||
marks = ", ".join(f":{c}" for c in row)
|
||||
with self.transaction() as conn:
|
||||
existed = conn.execute("SELECT 1 FROM roles WHERE uid=?",
|
||||
(row["uid"],)).fetchone() is not None
|
||||
before = conn.execute("SELECT description FROM roles WHERE uid=?",
|
||||
(row["uid"],)).fetchone()
|
||||
conn.execute(
|
||||
f"INSERT INTO roles ({columns}) VALUES ({marks}) "
|
||||
f"ON CONFLICT(uid) DO UPDATE SET {', '.join(updates)}", row)
|
||||
return not existed
|
||||
# A role listed without its text is embedded from its title, and
|
||||
# `embed` encodes a role once. When the text arrives on a later
|
||||
# pull, as it does for a host that states it on the role's own
|
||||
# page, the vector goes, so the next `embed` reads the text.
|
||||
if before is not None and not before["description"] and row["description"]:
|
||||
conn.execute("DELETE FROM vectors WHERE uid=?", (row["uid"],))
|
||||
return before is None
|
||||
|
||||
def role(self, uid: str, agent_id: int | None = None) -> ScoredRole | None:
|
||||
"""One role with its tags, and with `vote`, `voted_at`, `score`,
|
||||
|
||||
Reference in new issue
Block a user