sunai / code /learning.py
kartik20032003's picture
Upload code/learning.py with huggingface_hub
d74ce48 verified
Raw History Blame Contribute Delete
716 Bytes
import subprocess
import sys
from database import save_conversation as _db_save, get_conversation_count
RETRAIN_EVERY = 5 # auto-retrain SunAI every N conversations
def save_conversation(user_input, bot_reply, intent="casual", tone="casual"):
_db_save(user_input, bot_reply, intent, tone)
_maybe_retrain()
def _maybe_retrain():
count = get_conversation_count()
if count % RETRAIN_EVERY == 0:
print(f"\n[SunAI] {count} conversations reached — retraining in background...\n")
subprocess.Popen(
[sys.executable, "sunai.py"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
creationflags=subprocess.CREATE_NO_WINDOW
)