mirror of
https://github.com/infinition/Bjorn.git
synced 2026-03-11 07:01:59 +00:00
Add RLUtils class for managing RL/AI dashboard endpoints
- Implemented methods for fetching AI stats, training history, and recent experiences. - Added functionality to set operation mode (MANUAL, AUTO, AI) with appropriate handling. - Included helper methods for querying the database and sending JSON responses. - Integrated model metadata extraction for visualization purposes.
This commit is contained in:
22
comment.py
22
comment.py
@@ -280,19 +280,23 @@ class CommentAI:
|
||||
if not rows:
|
||||
return None
|
||||
|
||||
# Weighted selection pool
|
||||
pool: List[str] = []
|
||||
# Weighted selection using random.choices (no temporary list expansion)
|
||||
texts: List[str] = []
|
||||
weights: List[int] = []
|
||||
for row in rows:
|
||||
try:
|
||||
w = int(_row_get(row, "weight", 1)) or 1
|
||||
except Exception:
|
||||
w = 1
|
||||
w = max(1, w)
|
||||
text = _row_get(row, "text", "")
|
||||
if text:
|
||||
pool.extend([text] * w)
|
||||
try:
|
||||
w = int(_row_get(row, "weight", 1)) or 1
|
||||
except Exception:
|
||||
w = 1
|
||||
texts.append(text)
|
||||
weights.append(max(1, w))
|
||||
|
||||
chosen = random.choice(pool) if pool else _row_get(rows[0], "text", None)
|
||||
if texts:
|
||||
chosen = random.choices(texts, weights=weights, k=1)[0]
|
||||
else:
|
||||
chosen = _row_get(rows[0], "text", None)
|
||||
|
||||
# Templates {var}
|
||||
if chosen and params:
|
||||
|
||||
Reference in New Issue
Block a user