Njap-png commited on
Commit
891707a
·
1 Parent(s): f16f362

Self-learn from every interaction (4+ exchanges, cooldown)

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -23,6 +23,7 @@ TRAIN_LOCK = threading.Lock()
23
 
24
  interactions = []
25
  training_state = {"running": False, "steps": 0, "last": "idle", "count_at_train": 0}
 
26
 
27
 
28
  def load_interactions():
@@ -303,8 +304,10 @@ def generate_response(message, history):
303
  "user": message,
304
  "assistant": response,
305
  })
306
- # adaptive trigger: learn every 8 new interactions
307
- if len(interactions) >= 8 and len(interactions) % 8 == 0 and not training_state["running"]:
 
 
308
  threading.Thread(target=learn_from_interactions, daemon=True).start()
309
  return response
310
 
 
23
 
24
  interactions = []
25
  training_state = {"running": False, "steps": 0, "last": "idle", "count_at_train": 0}
26
+ LAST_TRAIN_TIME = 0.0
27
 
28
 
29
  def load_interactions():
 
304
  "user": message,
305
  "assistant": response,
306
  })
307
+ # adaptive trigger: self-learn from every conversation (cooldown 30s)
308
+ global LAST_TRAIN_TIME
309
+ if len(interactions) >= 4 and not training_state["running"] and (time.time() - LAST_TRAIN_TIME) >= 120:
310
+ LAST_TRAIN_TIME = time.time()
311
  threading.Thread(target=learn_from_interactions, daemon=True).start()
312
  return response
313