Update modules/memory.py
Browse files- modules/memory.py +34 -11
modules/memory.py
CHANGED
@@ -14,16 +14,39 @@ import random
|
|
14 |
class Memory:
|
15 |
"""Klasse zur Verwaltung des Gesprächsgedächtnisses"""
|
16 |
|
17 |
-
def
|
18 |
-
"""
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def add_exchange(self, user_input: str, bot_response: str, analysis: Optional[Dict[str, Any]] = None) -> None:
|
29 |
"""
|
@@ -215,4 +238,4 @@ class Memory:
|
|
215 |
"time": time.time(),
|
216 |
"intensity": analysis.get("intensity", 0),
|
217 |
"patterns": analysis.get("patterns", [])
|
218 |
-
}
|
|
|
14 |
class Memory:
|
15 |
"""Klasse zur Verwaltung des Gesprächsgedächtnisses"""
|
16 |
|
17 |
+
def _extract_information(self, exchange: Dict[str, Any]) -> None:
|
18 |
+
"""
|
19 |
+
Extrahiert wichtige Informationen aus einem Gesprächsaustausch
|
20 |
+
|
21 |
+
Args:
|
22 |
+
exchange: Dictionary mit User-Input und Bot-Response
|
23 |
+
|
24 |
+
Raises:
|
25 |
+
ValueError: Wenn der Exchange ungültig ist
|
26 |
+
"""
|
27 |
+
if not isinstance(exchange, dict):
|
28 |
+
raise ValueError("exchange must be a dictionary")
|
29 |
+
if "user_input" not in exchange or not isinstance(exchange["user_input"], str):
|
30 |
+
raise ValueError("exchange must contain valid user_input")
|
31 |
+
|
32 |
+
user_input = exchange["user_input"].lower()
|
33 |
+
analysis = exchange["analysis"]
|
34 |
+
|
35 |
+
try:
|
36 |
+
# Multi-Level Psychoanalyse
|
37 |
+
self._analyze_defense_mechanisms(user_input)
|
38 |
+
self._analyze_transference_patterns(user_input)
|
39 |
+
self._analyze_symbolic_patterns(user_input)
|
40 |
+
self._update_association_network(user_input)
|
41 |
+
self._update_escalation_levels(analysis)
|
42 |
+
|
43 |
+
# Erwähnte Personen und Ereignisse
|
44 |
+
for word in user_input.split():
|
45 |
+
if word not in ["ich", "du", "wir", "sie", "er", "es"]:
|
46 |
+
self.extracted_info["mentioned_people"].add(word)
|
47 |
+
|
48 |
+
except Exception as e:
|
49 |
+
raise ValueError(f"Failed to extract information: {str(e)}")
|
50 |
|
51 |
def add_exchange(self, user_input: str, bot_response: str, analysis: Optional[Dict[str, Any]] = None) -> None:
|
52 |
"""
|
|
|
238 |
"time": time.time(),
|
239 |
"intensity": analysis.get("intensity", 0),
|
240 |
"patterns": analysis.get("patterns", [])
|
241 |
+
}
|