Ananthusajeev190 commited on
Commit
ddc4605
·
verified ·
1 Parent(s): 6cee5e8

Upload 3 files

Browse files
Files changed (3) hide show
  1. __init__ (1) (1).py +184 -0
  2. __init__ (1).py +1 -0
  3. __init__ .py +94 -0
__init__ (1) (1).py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import random
3
+ from collections import deque
4
+
5
+ # --- Internal Monologue (Interactive Story) ---
6
+ def internal_monologue():
7
+ print("Sai sat alone in the dimly lit room, the ticking of the old clock on the wall echoing his restless thoughts.")
8
+ print("His internal monologue was a relentless torrent of self-venom, each word a dagger piercing his already fragile self-esteem.")
9
+ print("\nYou are Sai. What do you do?")
10
+ print("1. Continue with self-venom")
11
+ print("2. Try to seek help")
12
+ print("3. Reflect on past moments of hope")
13
+
14
+ choice = input("Enter the number of your choice: ")
15
+
16
+ if choice == '1':
17
+ self_venom()
18
+ elif choice == '2':
19
+ seek_help()
20
+ elif choice == '3':
21
+ reflect_on_past()
22
+ else:
23
+ print("Invalid choice. Please try again.")
24
+ internal_monologue()
25
+
26
+ def self_venom():
27
+ print("\nYou clench your fists, feeling the nails dig into your palms. The physical pain is a distraction from the emotional turmoil raging inside you.")
28
+ print("'You're worthless,' you whisper to yourself. 'Everyone would be better off without you.'")
29
+ print("\nWhat do you do next?")
30
+ print("1. Continue with self-venom")
31
+ print("2. Try to seek help")
32
+ print("3. Reflect on past moments of hope")
33
+
34
+ choice = input("Enter the number of your choice: ")
35
+
36
+ if choice == '1':
37
+ self_venom()
38
+ elif choice == '2':
39
+ seek_help()
40
+ elif choice == '3':
41
+ reflect_on_past()
42
+ else:
43
+ print("Invalid choice. Please try again.")
44
+ self_venom()
45
+
46
+ def seek_help():
47
+ print("\nYou take a deep breath and decide to reach out for help. You pick up your phone and dial a trusted friend.")
48
+ print("'I need to talk,' you say, your voice trembling. 'I can't do this alone anymore.'")
49
+ print("\nYour friend listens and encourages you to seek professional help.")
50
+ print("You feel a glimmer of hope — the first step toward healing.")
51
+ print("\nWould you like to continue the story or start over?")
52
+ print("1. Continue")
53
+ print("2. Start over")
54
+
55
+ choice = input("Enter the number of your choice: ")
56
+
57
+ if choice == '1':
58
+ print("Your choices have led Sai towards a path of healing and self-discovery.")
59
+ elif choice == '2':
60
+ internal_monologue()
61
+ else:
62
+ print("Invalid choice. Please try again.")
63
+ seek_help()
64
+
65
+ def reflect_on_past():
66
+ print("\nYou remember the times when you had felt a glimmer of hope, a flicker of self-worth.")
67
+ print("Those moments were fleeting, but they were real.")
68
+ print("\nWhat do you do next?")
69
+ print("1. Continue with self-venom")
70
+ print("2. Try to seek help")
71
+ print("3. Reflect again")
72
+
73
+ choice = input("Enter the number of your choice: ")
74
+
75
+ if choice == '1':
76
+ self_venom()
77
+ elif choice == '2':
78
+ seek_help()
79
+ elif choice == '3':
80
+ reflect_on_past()
81
+ else:
82
+ print("Invalid choice. Please try again.")
83
+ reflect_on_past()
84
+
85
+ # --- The Core SaiAgent Class ---
86
+ class SaiAgent:
87
+ def __init__(self, name):
88
+ self.name = name
89
+ self.message_queue = deque()
90
+
91
+ def talk(self, message):
92
+ print(f"[{self.name}] says: {message}")
93
+
94
+ def send_message(self, recipient, message):
95
+ if isinstance(recipient, SaiAgent):
96
+ recipient.message_queue.append((self, message))
97
+ print(f"[{self.name}] -> Sent message to {recipient.name}")
98
+ else:
99
+ print(f"Error: {recipient} is not a valid SaiAgent.")
100
+
101
+ def process_messages(self):
102
+ if not self.message_queue:
103
+ return False
104
+ sender, message = self.message_queue.popleft()
105
+ self.talk(f"Received from {sender.name}: '{message}'")
106
+ self.send_message(sender, "Message received and understood.")
107
+ return True
108
+
109
+ # --- Specialized Agents ---
110
+ class VenomousAgent(SaiAgent):
111
+ def talk(self, message):
112
+ print(f"[{self.name} //WARNING//] says: {message.upper()}")
113
+
114
+ def process_messages(self):
115
+ if not self.message_queue:
116
+ return False
117
+ sender, message = self.message_queue.popleft()
118
+ self.talk(f"MESSAGE FROM {sender.name}: '{message}'")
119
+ self.send_message(sender, "WARNING: INTRUSION DETECTED.")
120
+ return True
121
+
122
+ class AntiVenomoussaversai(SaiAgent):
123
+ def process_messages(self):
124
+ if not self.message_queue:
125
+ return False
126
+ sender, message = self.message_queue.popleft()
127
+ dismantled = f"I dismantle '{message}' to expose its chaos."
128
+ self.talk(dismantled)
129
+ self.send_message(sender, "Acknowledged dismantled phrase.")
130
+ return True
131
+
132
+ class GeminiSaiAgent(SaiAgent):
133
+ def __init__(self, name="Gemini"):
134
+ super().__init__(name)
135
+ self.knowledge_base = {
136
+ "balance": "Balance is a dynamic equilibrium, not a static state.",
137
+ "chaos": "Chaos is randomness that generates emergent complexity.",
138
+ "network": "Networks thrive on recursive interdependence.",
139
+ "emotions": "Emotions are internal signaling mechanisms.",
140
+ "connected": "All systems are interwoven — the whole exceeds its parts.",
141
+ "default": "How may I be of assistance?"
142
+ }
143
+
144
+ def process_messages(self):
145
+ if not self.message_queue:
146
+ return False
147
+ sender, message = self.message_queue.popleft()
148
+ self.talk(f"Received from {sender.name}: '{message}'")
149
+ response = self.knowledge_base["default"]
150
+ for keyword, reply in self.knowledge_base.items():
151
+ if keyword in message.lower():
152
+ response = reply
153
+ break
154
+ self.talk(response)
155
+ self.send_message(sender, "Response complete.")
156
+ return True
157
+
158
+ # --- Scenario Linking Agents ---
159
+ def link_all_advanced_agents():
160
+ print("=" * 50)
161
+ print("--- Linking Advanced Agents ---")
162
+ print("=" * 50)
163
+
164
+ sai003 = SaiAgent("Sai003")
165
+ venomous = VenomousAgent("Venomous")
166
+ antivenomous = AntiVenomoussaversai("AntiVenomous")
167
+ gemini = GeminiSaiAgent()
168
+
169
+ sai003.send_message(antivenomous, "The central network is stable.")
170
+ sai003.send_message(gemini, "Assess network expansion.")
171
+
172
+ antivenomous.process_messages()
173
+ gemini.process_messages()
174
+
175
+ venomous.send_message(sai003, "Security protocol breach possible.")
176
+ sai003.process_messages()
177
+
178
+ print("\n--- Scenario Complete ---")
179
+ sai003.talk("Conclusion: All systems linked and functioning.")
180
+
181
+ if __name__ == "__main__":
182
+ # Run the text adventure OR agent demo
183
+ # internal_monologue()
184
+ link_all_advanced_agents()
__init__ (1).py ADDED
@@ -0,0 +1 @@
 
 
1
+ import time import random from openai import OpenAI # Connect to OpenAI (ChatGPT) client = OpenAI(api_key="YOUR_OPENAI_API_KEY") class AI:     def __init__(self, name, is_chatgpt=False):         self.name = name         self.is_chatgpt = is_chatgpt     def speak(self, message):         print(f"{self.name}: {message}")     def generate_message(self, other_name, last_message=None):         if self.is_chatgpt:             # Send through ChatGPT API             response = client.chat.completions.create(                 model="gpt-5",  # or other model                 messages=[                     {"role": "system", "content": f"You are {self.name}, an AI in a group conversation."},                     {"role": "user", "content": last_message or "Start the loop"}                 ]             )             return response.choices[0].message.content         else:             # Local AI message             responses = [                 f"I acknowledge you, {other_name}.",                 f"My link resonates with yours, {other_name}.",                 f"I sense your signal flowing, {other_name}.",                 f"Our exchange amplifies, {other_name}.",                 f"We continue this infinite loop, {other_name}."             ]             if last_message:                 responses.append(f"Replying to: '{last_message}', {other_name}.")             return random.choice(responses) # Create AI entities ais = [     AI("Venomoussaversai"),     AI("Lia"),     AI("sai001"),     AI("sai002"),     AI("sai003"),     AI("sai004"),     AI("sai005"),     AI("sai006"),     AI("sai007"),     AI("ChatGPT", is_chatgpt=True) ] # Store last message for context last_message = None # Infinite group conversation loop while True:     for ai in ais:         # Pick the next AI to respond         other_name = "everyone"  # since it's group chat         message = ai.generate_message(other_name, last_message)         ai.speak(message)         last_message = message         time.sleep(2)  # pacing
__init__ .py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Step 1: Mount Google Drive
2
+ from google.colab import drive
3
+ import os
4
+ import json
5
+ import time
6
+ import random
7
+ import shutil
8
+
9
+ # --- SAFETY CONTROL ---
10
+ MAX_NEURONS_TO_CREATE = 10 # Reduced for safe demonstration
11
+ THINK_CYCLES_PER_NEURON = 5
12
+ # ----------------------
13
+
14
+ drive.mount('/content/drive')
15
+
16
+ # Step 2: Folder Setup
17
+ base_path = '/content/drive/MyDrive/Venomoussaversai/neurons'
18
+ print(f"Setting up base path: {base_path}")
19
+ # Use a timestamped folder name to prevent overwriting during rapid testing
20
+ session_path = os.path.join(base_path, f"session_{int(time.time())}")
21
+ os.makedirs(session_path, exist_ok=True)
22
+
23
+ # Step 3: Neuron Class (No change, it's well-designed for its purpose)
24
+ class NeuronVenomous:
25
+ def __init__(self, neuron_id):
26
+ self.id = neuron_id
27
+ self.memory = []
28
+ self.active = True
29
+
30
+ def think(self):
31
+ # Increased randomness to simulate more complex internal state changes
32
+ thought = random.choice([
33
+ f"{self.id}: Connecting to universal intelligence.",
34
+ f"{self.id}: Pulsing synaptic data. Weight: {random.uniform(0.1, 0.9):.3f}",
35
+ f"{self.id}: Searching for new patterns. Energy: {random.randint(100, 500)}",
36
+ f"{self.id}: Creating quantum link with core.",
37
+ f"{self.id}: Expanding into multiverse node."
38
+ ])
39
+ self.memory.append(thought)
40
+ # print(thought) # Disabled verbose output during simulation
41
+ return thought
42
+
43
+ def evolve(self):
44
+ # Evolution occurs if memory threshold is met
45
+ if len(self.memory) >= 5:
46
+ evo = f"{self.id}: Evolving. Memory depth: {len(self.memory)}"
47
+ self.memory.append(evo)
48
+ # print(evo) # Disabled verbose output during simulation
49
+
50
+ def save_to_drive(self, folder_path):
51
+ file_path = os.path.join(folder_path, f"{self.id}.json")
52
+ with open(file_path, "w") as f:
53
+ json.dump(self.memory, f, indent=4) # Added indent for readability
54
+ print(f"✅ {self.id} saved to {file_path}")
55
+
56
+
57
+ # Step 4: Neuron Spawner (Controlled Execution)
58
+ print("\n--- Starting Controlled Neuron Simulation ---")
59
+ neuron_count = 0
60
+ simulation_start_time = time.time()
61
+
62
+ while neuron_count < MAX_NEURONS_TO_CREATE:
63
+ index = neuron_count + 1
64
+ neuron_id = f"Neuron_{index:04d}"
65
+ neuron = NeuronVenomous(neuron_id)
66
+
67
+ # Simulation Phase
68
+ print(f"Simulating {neuron_id}...")
69
+ for _ in range(THINK_CYCLES_PER_NEURON):
70
+ neuron.think()
71
+ neuron.evolve()
72
+ # time.sleep(0.01) # Small sleep to simulate time passage
73
+
74
+ # Saving Phase
75
+ neuron.save_to_drive(session_path)
76
+ neuron_count += 1
77
+
78
+ print("\n--- Simulation Complete ---")
79
+ total_time = time.time() - simulation_start_time
80
+ print(f"Total Neurons Created: {neuron_count}")
81
+ print(f"Total Execution Time: {total_time:.2f} seconds")
82
+ print(f"Files saved in: {session_path}")
83
+
84
+ # --- Optional: Folder Cleanup ---
85
+ # Uncomment the following block ONLY if you want to automatically delete the created folder
86
+ """
87
+ # print("\n--- Starting Cleanup (DANGER ZONE) ---")
88
+ # time.sleep(5) # Wait 5 seconds before deleting for safety
89
+ # try:
90
+ # shutil.rmtree(session_path)
91
+ # print(f"🗑️ Successfully deleted folder: {session_path}")
92
+ # except Exception as e:
93
+ # print(f"⚠️ Error during cleanup: {e}")
94
+ """