Release beta 1.1.0 scan and duplicate fixes
This commit is contained in:
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "jwebot-kernel"
|
||||
version = "1.0.5b1+1016"
|
||||
version = "1.1.0b1+1016"
|
||||
description = "Stable routing and extension authority for JWeBot"
|
||||
requires-python = ">=3.9"
|
||||
dependencies = [
|
||||
"jwebot-config==1.0.5b1+1016",
|
||||
"jwebot-sdk==1.0.5b1+1016",
|
||||
"jwebot-official-extensions==1.0.5b1+1016",
|
||||
"jwebot-config==1.1.0b1+1016",
|
||||
"jwebot-sdk==1.1.0b1+1016",
|
||||
"jwebot-official-extensions==1.1.0b1+1016",
|
||||
"tomli>=2; python_version < '3.11'",
|
||||
]
|
||||
|
||||
|
||||
@@ -107,4 +107,4 @@ __all__ = [
|
||||
"verify_installed_release_signature",
|
||||
]
|
||||
|
||||
__version__ = "1.0.5b1+1016"
|
||||
__version__ = "1.1.0b1+1016"
|
||||
|
||||
@@ -104,6 +104,18 @@ MAX_EVENT_TEXT = 5_000
|
||||
MAX_REPLY_CHARS = 900
|
||||
MAX_CONTEXT_TURNS = 6
|
||||
OCR_EVENT_SOURCES = frozenset({"ocr", "rapidocr-local"})
|
||||
OCR_SEMANTIC_DUPLICATE_SECONDS = 8.0
|
||||
OCR_RESOURCE_MUTATION_DUPLICATE_SECONDS = 75.0
|
||||
OCR_RESOURCE_MUTATION_REASONS = frozenset(
|
||||
{
|
||||
"local_loan",
|
||||
"local_primogem_wish",
|
||||
"local_repay",
|
||||
"local_scan_boost",
|
||||
"local_taffy_say",
|
||||
"local_transfer",
|
||||
}
|
||||
)
|
||||
MAX_OUTBOX_ATTEMPTS = 3
|
||||
DIRECT_CHAT_GENERATION_WORKERS = 2
|
||||
DIRECT_API_SOCKET_TIMEOUT_SECONDS = 18.0
|
||||
@@ -2985,6 +2997,85 @@ class Ledger:
|
||||
).fetchall()
|
||||
return [dict(row) for row in rows]
|
||||
|
||||
def clock_scan_ranking_all(
|
||||
self,
|
||||
group_fingerprint: str,
|
||||
local_date: str,
|
||||
) -> list[dict[str, Any]]:
|
||||
group = bounded_text(group_fingerprint, limit=256)
|
||||
people: dict[str, dict[str, Any]] = {}
|
||||
for person in self.person_directory(group):
|
||||
people[str(person["person_key"])] = {
|
||||
"person_key": str(person["person_key"]),
|
||||
"display_name": str(person["display_name"]),
|
||||
"scan_count": 0,
|
||||
}
|
||||
with self.lock:
|
||||
rows = self.connection.execute(
|
||||
"""
|
||||
SELECT person_key, display_name, scan_count
|
||||
FROM clock_scan_scores
|
||||
WHERE group_fingerprint = ? AND local_date = ?
|
||||
""",
|
||||
(group, local_date),
|
||||
).fetchall()
|
||||
for row in rows:
|
||||
person_key = str(row["person_key"])
|
||||
people[person_key] = {
|
||||
"person_key": person_key,
|
||||
"display_name": str(row["display_name"]),
|
||||
"scan_count": int(row["scan_count"]),
|
||||
}
|
||||
people_list = list(people.values())
|
||||
people_list.sort(
|
||||
key=lambda item: (
|
||||
-int(item["scan_count"]),
|
||||
str(item["display_name"]).casefold(),
|
||||
)
|
||||
)
|
||||
return people_list
|
||||
|
||||
def next_clock_scan_weights(
|
||||
self,
|
||||
group_fingerprint: str,
|
||||
) -> list[dict[str, Any]]:
|
||||
group = bounded_text(group_fingerprint, limit=256)
|
||||
weights: dict[str, dict[str, Any]] = {}
|
||||
for person in self.person_directory(group):
|
||||
weights[str(person["person_key"])] = {
|
||||
"person_key": str(person["person_key"]),
|
||||
"display_name": str(person["display_name"]),
|
||||
"weight": 1,
|
||||
}
|
||||
for canonical_name, scan_label in CLOCK_SCAN_TARGETS:
|
||||
person_key = person_scope_key(group, canonical_name)
|
||||
weights.setdefault(
|
||||
person_key,
|
||||
{
|
||||
"person_key": person_key,
|
||||
"display_name": scan_label,
|
||||
"weight": 1,
|
||||
},
|
||||
)
|
||||
for person_key, boost in self.active_scan_boost_targets(group).items():
|
||||
entry = weights.setdefault(
|
||||
person_key,
|
||||
{
|
||||
"person_key": person_key,
|
||||
"display_name": str(boost["display_name"]),
|
||||
"weight": 1,
|
||||
},
|
||||
)
|
||||
entry["weight"] += int(boost.get("extra_weight", 0))
|
||||
weight_list = list(weights.values())
|
||||
weight_list.sort(
|
||||
key=lambda item: (
|
||||
-int(item["weight"]),
|
||||
str(item["display_name"]).casefold(),
|
||||
)
|
||||
)
|
||||
return weight_list
|
||||
|
||||
def record_dice_challenge_achievement(
|
||||
self,
|
||||
*,
|
||||
@@ -6979,12 +7070,18 @@ class EdgeApplication:
|
||||
existing_row = self.ledger.row(event_id) if event_id else None
|
||||
semantic_duplicate = None
|
||||
if existing_row is None and is_ocr_event(event):
|
||||
duplicate_window = (
|
||||
OCR_RESOURCE_MUTATION_DUPLICATE_SECONDS
|
||||
if reason in OCR_RESOURCE_MUTATION_REASONS
|
||||
else OCR_SEMANTIC_DUPLICATE_SECONDS
|
||||
)
|
||||
semantic_duplicate = self.ledger.recent_semantic_duplicate(
|
||||
group_fingerprint=group_id,
|
||||
sender=str(event.get("sender", "")),
|
||||
question=question,
|
||||
route=route,
|
||||
route_reason=reason,
|
||||
within_seconds=duplicate_window,
|
||||
)
|
||||
if semantic_duplicate is not None:
|
||||
self.telemetry.elapsed(
|
||||
|
||||
Reference in New Issue
Block a user