Frajosgro commited on
Commit
8c9541f
·
verified ·
1 Parent(s): 1b554cf

Update modules/memory.py

Browse files
Files changed (1) hide show
  1. 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 __init__(self, max_history_length: int = 10):
18
- """Initialisiert das Gedächtnis mit maximaler Historienlänge"""
19
- self.max_history_length = max_history_length
20
- self.conversation_history = []
21
- self.extracted_info = {
22
- "mentioned_people": set(),
23
- "mentioned_events": set(),
24
- "recurring_themes": {},
25
- "emotional_patterns": []
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
+ }