Update modules/persona.py
Browse files- modules/persona.py +22 -16
modules/persona.py
CHANGED
@@ -42,10 +42,11 @@ class Persona:
|
|
42 |
Returns:
|
43 |
Ein Dictionary mit Anweisungen für die Antwortgenerierung
|
44 |
"""
|
|
|
45 |
strategy = {
|
46 |
"tone": self._determine_tone(emotion),
|
47 |
"focus": self._determine_focus(user_input),
|
48 |
-
"technique": self._determine_technique(emotion,
|
49 |
"intensity_modifier": self.intensity / 3.0 # Skalierungsfaktor für die Intensität
|
50 |
}
|
51 |
|
@@ -89,21 +90,25 @@ class Persona:
|
|
89 |
# Normalisieren der Gewichte
|
90 |
total = sum(weights)
|
91 |
weights = [w / total for w in weights]
|
|
|
|
|
|
|
92 |
|
93 |
def _determine_technique(self, emotion: Optional[str], manipulation_opportunities: List[str]) -> str:
|
94 |
"""Bestimmt die Antworttechnik basierend auf Emotion und Manipulationsmöglichkeiten"""
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
else:
|
103 |
-
techniques = ["analytisch", "suggestiv", "manipulativ", "bohrend"]
|
104 |
-
weights = [0.3, 0.3, 0.2, 0.2]
|
105 |
else:
|
106 |
-
|
|
|
|
|
|
|
|
|
107 |
if "unsicherheit" in manipulation_opportunities:
|
108 |
techniques = ["analytisch", "bohrend", "suggestiv", "manipulativ"]
|
109 |
weights = [0.4, 0.3, 0.2, 0.1]
|
@@ -114,8 +119,11 @@ class Persona:
|
|
114 |
techniques = ["suggestiv", "manipulativ", "analytisch", "bohrend"]
|
115 |
weights = [0.4, 0.3, 0.2, 0.1]
|
116 |
else:
|
117 |
-
techniques =
|
118 |
-
weights =
|
|
|
|
|
|
|
119 |
|
120 |
# Intensität beeinflusst die Gewichtung
|
121 |
if self.intensity >= 4:
|
@@ -127,8 +135,6 @@ class Persona:
|
|
127 |
|
128 |
# Wähle eine Technik basierend auf den Gewichten
|
129 |
return random.choices(techniques, weights=weights)[0]
|
130 |
-
|
131 |
-
return random.choices(tones, weights=weights, k=1)[0]
|
132 |
|
133 |
def _determine_focus(self, user_input: str) -> str:
|
134 |
"""Bestimmt den Fokus der Antwort basierend auf der Nutzereingabe"""
|
|
|
42 |
Returns:
|
43 |
Ein Dictionary mit Anweisungen für die Antwortgenerierung
|
44 |
"""
|
45 |
+
opportunities = self._determine_manipulation_opportunities(user_input)
|
46 |
strategy = {
|
47 |
"tone": self._determine_tone(emotion),
|
48 |
"focus": self._determine_focus(user_input),
|
49 |
+
"technique": self._determine_technique(emotion, opportunities),
|
50 |
"intensity_modifier": self.intensity / 3.0 # Skalierungsfaktor für die Intensität
|
51 |
}
|
52 |
|
|
|
90 |
# Normalisieren der Gewichte
|
91 |
total = sum(weights)
|
92 |
weights = [w / total for w in weights]
|
93 |
+
|
94 |
+
# Wähle einen Ton basierend auf den Gewichten
|
95 |
+
return random.choices(tones, weights=weights)[0]
|
96 |
|
97 |
def _determine_technique(self, emotion: Optional[str], manipulation_opportunities: List[str]) -> str:
|
98 |
"""Bestimmt die Antworttechnik basierend auf Emotion und Manipulationsmöglichkeiten"""
|
99 |
+
# Standardtechniken basierend auf Emotion
|
100 |
+
if emotion == "negative":
|
101 |
+
base_techniques = ["konfrontativ", "analytisch", "bohrend", "herablassend"]
|
102 |
+
base_weights = [0.3, 0.3, 0.2, 0.2]
|
103 |
+
elif emotion == "positive":
|
104 |
+
base_techniques = ["suggestiv", "manipulativ", "analytisch", "herablassend"]
|
105 |
+
base_weights = [0.3, 0.3, 0.2, 0.2]
|
|
|
|
|
|
|
106 |
else:
|
107 |
+
base_techniques = ["analytisch", "suggestiv", "manipulativ", "bohrend"]
|
108 |
+
base_weights = [0.3, 0.3, 0.2, 0.2]
|
109 |
+
|
110 |
+
# Anpassung der Techniken basierend auf Manipulationsmöglichkeiten
|
111 |
+
if manipulation_opportunities:
|
112 |
if "unsicherheit" in manipulation_opportunities:
|
113 |
techniques = ["analytisch", "bohrend", "suggestiv", "manipulativ"]
|
114 |
weights = [0.4, 0.3, 0.2, 0.1]
|
|
|
119 |
techniques = ["suggestiv", "manipulativ", "analytisch", "bohrend"]
|
120 |
weights = [0.4, 0.3, 0.2, 0.1]
|
121 |
else:
|
122 |
+
techniques = base_techniques
|
123 |
+
weights = base_weights
|
124 |
+
else:
|
125 |
+
techniques = base_techniques
|
126 |
+
weights = base_weights
|
127 |
|
128 |
# Intensität beeinflusst die Gewichtung
|
129 |
if self.intensity >= 4:
|
|
|
135 |
|
136 |
# Wähle eine Technik basierend auf den Gewichten
|
137 |
return random.choices(techniques, weights=weights)[0]
|
|
|
|
|
138 |
|
139 |
def _determine_focus(self, user_input: str) -> str:
|
140 |
"""Bestimmt den Fokus der Antwort basierend auf der Nutzereingabe"""
|