Spaces:
Sleeping
Sleeping
Update quantum_learner.py
Browse files- quantum_learner.py +17 -12
quantum_learner.py
CHANGED
|
@@ -5,17 +5,22 @@ import numpy as np
|
|
| 5 |
|
| 6 |
class QuantumLearner:
|
| 7 |
def __init__(self):
|
|
|
|
| 8 |
self.model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')
|
|
|
|
| 9 |
|
| 10 |
-
def analyze_conversations(self):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
class QuantumLearner:
|
| 7 |
def __init__(self):
|
| 8 |
+
# Koristimo lightweight multi-jezički model
|
| 9 |
self.model = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2')
|
| 10 |
+
self.model.max_seq_length = 256 # Optimizacija za performanse
|
| 11 |
|
| 12 |
+
def analyze_conversations(self, history_limit=1000):
|
| 13 |
+
"""Analizira razgovore i pronalazi ključne teme"""
|
| 14 |
+
try:
|
| 15 |
+
history = get_history(limit=history_limit)
|
| 16 |
+
if not history:
|
| 17 |
+
return {"info": "Nema dostupne povijesti za analizu"}
|
| 18 |
+
|
| 19 |
+
# Dekriptiraj i kombinuj poruke
|
| 20 |
+
texts = [
|
| 21 |
+
f"{decrypt_data(row[2])} → {decrypt_data(row[3])}"
|
| 22 |
+
for row in history
|
| 23 |
+
if len(row) >= 4 # Zaštita od nepotpunih podataka
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
# Vektorizacija teksta
|