-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemoryChatGpt.py
63 lines (50 loc) · 2.49 KB
/
MemoryChatGpt.py
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
import psutil
import os
import time
class MemoryInitiatorSysCommander:
def __init__(self):
self.knowBefore = [
"memoryContract", "silentMeasurement", "digitalMemorySensor",
"thoughtForce", "computerFreq", "signalTracer"
]
def log_system_information(self):
"""Collect network connections, CPU usage, and memory usage."""
connections = psutil.net_connections(kind='all')
cpu_usage = psutil.cpu_percent(interval=1)
memory_usage = psutil.virtual_memory()
# For debugging or logging purposes
print(f"Network Connections: {connections}")
print(f"CPU Usage: {cpu_usage}%")
print(f"Memory Usage: {memory_usage.percent}%")
return connections, cpu_usage, memory_usage
def evaluate_conditions(self, connections, cpu_usage, memory_usage):
"""Evaluate whether system conditions meet the criteria to trigger tasks."""
if connections and cpu_usage < 80 and memory_usage.percent < 90:
return True
return False
def initiate_commands(self, start_conditions_met=True):
"""Initiate predefined tasks if conditions are met."""
if start_conditions_met:
for task in self.knowBefore:
print(f"Initiating task: {task}")
self.perform_motivation_commands()
else:
print("Conditions not met for initiation.")
def perform_motivation_commands(self):
"""Perform some system tasks or commands to trigger 'motive' action."""
print("Performing high-powered motivational system tasks...")
os.system("echo Running high-power tasks...")
def operating_initiator(self):
"""Continuously check system conditions and perform actions in a loop."""
while True:
# Gather system data
connections, cpu_usage, memory_usage = self.log_system_information()
# Evaluate conditions to decide whether to initiate tasks
conditions_met = self.evaluate_conditions(connections, cpu_usage, memory_usage)
# If conditions are met, initiate the tasks
self.initiate_commands(conditions_met)
# Pause for a few seconds before repeating the check
time.sleep(10) # Adjust the time as needed for the frequency of checks
# Instantiate and execute the loop
memory_initiator = MemoryInitiatorSysCommander()
memory_initiator.operating_initiator()