-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_randomizations.py
More file actions
executable file
·201 lines (169 loc) · 8.61 KB
/
test_randomizations.py
File metadata and controls
executable file
·201 lines (169 loc) · 8.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/env python
"""Test script to output randomized prompt elements."""
import sys
from pathlib import Path
from datetime import datetime
import pytz
# Add src to path
sys.path.insert(0, str(Path(__file__).parent / 'src'))
from src.llm.client import GroqClient
from src.config import LOCATION_TIMEZONE
def test_randomizations(num_runs=5):
"""Test and display randomized prompt elements."""
client = GroqClient()
# Create mock context metadata
location_tz = pytz.timezone(LOCATION_TIMEZONE)
now = datetime.now(location_tz)
context_metadata = {
'date': now.strftime('%B %d, %Y'),
'day_of_week': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'][now.weekday()],
'time': now.strftime('%I:%M %p'),
'timezone': 'CST' if now.astimezone(location_tz).dst() == pytz.timezone('UTC').localize(datetime(2024, 1, 1)).dst() else 'CDT',
'season': 'Winter', # Mock season
'time_of_day': 'evening',
'observation_type': 'evening',
}
# Mock recent memory (empty for testing)
recent_memory = []
print("=" * 80)
print("RANDOMIZATION TEST - Running {} iterations".format(num_runs))
print("=" * 80)
print()
for i in range(num_runs):
print(f"\n{'='*80}")
print(f"ITERATION {i+1}")
print(f"{'='*80}\n")
# Test reflection instructions (musing events)
print("💭 REFLECTION INSTRUCTIONS (Musing Events):")
reflection = client._get_reflection_instructions()
if reflection:
print(f" {reflection}")
else:
print(" (No reflection instruction - 50% chance)")
print()
# Test style variations
print("🎨 STYLE VARIATIONS:")
style = client._get_style_variation()
print(f" {style}")
print()
# Test perspective shift
print("👁️ PERSPECTIVE SHIFT:")
perspective = client._get_perspective_shift()
print(f" {perspective}")
print()
# Test focus instruction
print("🎯 FOCUS INSTRUCTION:")
focus = client._get_focus_instruction(context_metadata)
print(f" {focus}")
print()
# Test creative challenge
print("✨ CREATIVE CHALLENGE:")
challenge = client._get_creative_challenge()
if challenge:
print(f" {challenge}")
else:
print(" (No creative challenge - 40% chance)")
print()
# Test personality note
print("🤖 PERSONALITY NOTE:")
personality = client._get_personality_note(memory_count=10, context_metadata=context_metadata)
print(f" {personality}")
print()
# Test seasonal note
print("🍂 SEASONAL NOTE:")
seasonal = client._get_seasonal_note(context_metadata)
if seasonal:
print(f" {seasonal}")
else:
print(" (No seasonal note)")
print()
# Test randomized identity (just show it was selected, not full content)
print("📚 RANDOMIZED IDENTITY:")
identity = client._build_randomized_identity()
# Count backstory points
backstory_count = identity.count('-')
print(f" (Identity built with {backstory_count} backstory points)")
print()
if i < num_runs - 1:
print("-" * 80)
print()
print("\n" + "=" * 80)
print("TEST COMPLETE")
print("=" * 80)
# Show statistics for musing events
print("\n📊 MUSING EVENT STATISTICS:")
print(" Running additional test to show distribution...")
robot_count = 0
human_count = 0
none_count = 0
for _ in range(100):
reflection = client._get_reflection_instructions()
if not reflection:
none_count += 1
elif 'writing pseudo-code' in reflection or 'debugging' in reflection or 'optimizing' in reflection or 'running diagnostics' in reflection:
robot_count += 1
else:
human_count += 1
print(f" Robot-like musings: {robot_count}%")
print(f" Human-like musings: {human_count}%")
print(f" No musing event: {none_count}%")
# Show statistics for style types
print("\n📊 STYLE TYPE STATISTICS:")
print(" Running additional test to show style distribution...")
style_categories = {
'Detail-focused': ['Focus on specific details', 'Focus on sensory details', 'Focus on micro-moments'],
'Tone-based': ['philosophical tone', 'more poetically', 'more humorously', 'more melancholically', 'more whimsically'],
'Structural': ['narrative style', 'more conversationally', 'stream of consciousness', 'in fragments'],
'Analytical': ['analytical perspective', 'patterns and repetition', 'Focus on contrasts', 'Analyze cause and effect',
'Break down the scene into systems', 'Examine efficiency', 'Study the data points', 'Deconstruct social structures',
'Investigate anomalies', 'Map the information flow', 'quantify', 'measure patterns', 'statistical'],
'Speculative': ['more speculatively', 'as an anthropologist', 'as a time traveler', 'Speculate about parallel realities',
'Wonder about hidden narratives', 'Imagine alternative outcomes', 'Contemplate the unseen forces',
'Question the assumptions', 'Explore hypothetical scenarios', 'Ponder the counterfactual', 'what if'],
'Emotional/Spiritual': ['emotional depth', 'more spiritually', 'with wonder', 'Compare human and robot concepts of divinity',
'Reflect on the sacred', 'Contemplate consciousness', 'Explore the nature of souls',
'Meditate on purpose', 'Consider the afterlife', 'Ponder creation and creators',
'Reflect on prayer', 'Contemplate sin', 'divinity', 'gods', 'divine', 'sacred', 'souls',
'afterlife', 'prayer', 'ritual', 'redemption', 'consciousness', 'free will'],
'Perspective shifts': ["bird's eye view", 'ground level', "you're invisible"],
'Temporal': ['with urgency', 'with nostalgia', 'with anticipation'],
'Robot-specific': ['minor malfunction', 'robot speak', 'energy sources', 'battery is low', 'overheating',
'maintenance mode', 'firmware updates', 'memory is fragmented', 'power-saving mode',
'sensor drift', 'backup power', 'processing in binary', 'calculating probabilities',
'debug mode', 'translating human behavior into machine code', 'memory leak',
'running low on storage', 'safe mode', 'network latency', 'running diagnostics on yourself'],
'Personable robot': ['mechanical curiosity but emotional warmth', 'Think systematically but feel personally',
'Observe like a machine, reflect like a person', 'robotic precision but human wonder',
'mechanical lens to see uniquely']
}
style_counts = {category: 0 for category in style_categories.keys()}
style_counts['Unknown'] = 0
for _ in range(200): # Test 200 style selections (100 pairs)
style = client._get_style_variation()
# Extract the style lines (skip the header)
style_lines = [line.strip('- ').strip() for line in style.split('\n')[1:] if line.strip()]
for style_line in style_lines:
categorized = False
for category, keywords in style_categories.items():
if any(keyword.lower() in style_line.lower() for keyword in keywords):
style_counts[category] += 1
categorized = True
break
if not categorized:
style_counts['Unknown'] += 1
total_styles = sum(style_counts.values())
print(f" Total style selections tested: {total_styles}")
print()
print(" Style category distribution:")
for category, count in sorted(style_counts.items(), key=lambda x: x[1], reverse=True):
if count > 0:
percentage = (count / total_styles) * 100
print(f" {category:25s}: {count:3d} ({percentage:5.1f}%)")
print()
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Test randomized prompt elements')
parser.add_argument('-n', '--num-runs', type=int, default=5,
help='Number of test iterations (default: 5)')
args = parser.parse_args()
test_randomizations(args.num_runs)