IamSatoshiAI commited on
Commit
0598506
·
verified ·
1 Parent(s): 1b182f0

Update quantum_learner.py

Browse files
Files changed (1) hide show
  1. 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
- history = get_history(limit=1000)
12
- texts = [decrypt_data(row[2]) + " " + decrypt_data(row[3]) for row in history]
13
-
14
- embeddings = self.model.encode(texts)
15
- kmeans = KMeans(n_clusters=3).fit(embeddings)
16
-
17
- topics = {}
18
- for label, text in zip(kmeans.labels_, texts):
19
- topics[label] = topics.get(label, []) + [text]
20
-
21
- return {k: v[:3] for k, v in topics.items()}
 
 
 
 
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