Update treinamento.py
Browse files- treinamento.py +2 -6
treinamento.py
CHANGED
|
@@ -4,7 +4,6 @@ import os
|
|
| 4 |
import threading
|
| 5 |
import time
|
| 6 |
import requests
|
| 7 |
-
from log pérd
|
| 8 |
from loguru import logger
|
| 9 |
from database import Database
|
| 10 |
from sentence_transformers import SentenceTransformer
|
|
@@ -68,7 +67,7 @@ class Treinamento:
|
|
| 68 |
self.thread.start()
|
| 69 |
logger.info("Loop de fine-tune iniciado!")
|
| 70 |
|
| 71 |
-
def registrar_interacao(self, usuario, mensagem, resposta, numero):
|
| 72 |
try:
|
| 73 |
# === SALVA NO BANCO ===
|
| 74 |
self.db.salvar_mensagem(usuario, mensagem, resposta, numero)
|
|
@@ -86,7 +85,7 @@ class Treinamento:
|
|
| 86 |
json.dump(entry, f, ensure_ascii=False)
|
| 87 |
f.write("\n")
|
| 88 |
|
| 89 |
-
logger.info(f"Kandando salvo: {
|
| 90 |
|
| 91 |
# === TREINA SE CHEGAR A 25 ===
|
| 92 |
if len(_dataset) >= self.min_interactions:
|
|
@@ -98,7 +97,6 @@ class Treinamento:
|
|
| 98 |
def _treinar(self):
|
| 99 |
if len(_dataset) < self.min_interactions:
|
| 100 |
return
|
| 101 |
-
|
| 102 |
logger.info(f"INICIANDO FINE-TUNE → {MODEL_FINE} com {len(_dataset)} kandandos")
|
| 103 |
|
| 104 |
try:
|
|
@@ -109,7 +107,6 @@ class Treinamento:
|
|
| 109 |
|
| 110 |
files = {'modelfile': open(MODelfile_PATH, 'rb')}
|
| 111 |
data = {'name': MODEL_FINE}
|
| 112 |
-
|
| 113 |
resp = requests.post("http://localhost:11434/api/create", files=files, data=data, timeout=600)
|
| 114 |
|
| 115 |
if resp.status_code == 200:
|
|
@@ -119,7 +116,6 @@ class Treinamento:
|
|
| 119 |
logger.error(f"Erro Ollama: {resp.status_code} {resp.text}")
|
| 120 |
|
| 121 |
os.remove(MODelfile_PATH)
|
| 122 |
-
|
| 123 |
except Exception as e:
|
| 124 |
logger.error(f"Erro no fine-tune: {e}")
|
| 125 |
|
|
|
|
| 4 |
import threading
|
| 5 |
import time
|
| 6 |
import requests
|
|
|
|
| 7 |
from loguru import logger
|
| 8 |
from database import Database
|
| 9 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 67 |
self.thread.start()
|
| 68 |
logger.info("Loop de fine-tune iniciado!")
|
| 69 |
|
| 70 |
+
def registrar_interacao(self, usuario, mensagem, resposta, numero, is_reply=False, mensagem_original=""):
|
| 71 |
try:
|
| 72 |
# === SALVA NO BANCO ===
|
| 73 |
self.db.salvar_mensagem(usuario, mensagem, resposta, numero)
|
|
|
|
| 85 |
json.dump(entry, f, ensure_ascii=False)
|
| 86 |
f.write("\n")
|
| 87 |
|
| 88 |
+
logger.info(f"Kandando salvo: {len(_dataset)} total")
|
| 89 |
|
| 90 |
# === TREINA SE CHEGAR A 25 ===
|
| 91 |
if len(_dataset) >= self.min_interactions:
|
|
|
|
| 97 |
def _treinar(self):
|
| 98 |
if len(_dataset) < self.min_interactions:
|
| 99 |
return
|
|
|
|
| 100 |
logger.info(f"INICIANDO FINE-TUNE → {MODEL_FINE} com {len(_dataset)} kandandos")
|
| 101 |
|
| 102 |
try:
|
|
|
|
| 107 |
|
| 108 |
files = {'modelfile': open(MODelfile_PATH, 'rb')}
|
| 109 |
data = {'name': MODEL_FINE}
|
|
|
|
| 110 |
resp = requests.post("http://localhost:11434/api/create", files=files, data=data, timeout=600)
|
| 111 |
|
| 112 |
if resp.status_code == 200:
|
|
|
|
| 116 |
logger.error(f"Erro Ollama: {resp.status_code} {resp.text}")
|
| 117 |
|
| 118 |
os.remove(MODelfile_PATH)
|
|
|
|
| 119 |
except Exception as e:
|
| 120 |
logger.error(f"Erro no fine-tune: {e}")
|
| 121 |
|