Files changed (5) hide show
  1. __init__ (1).py +49 -0
  2. __init__ (2) (1).py +101 -0
  3. __init__ (2).py +100 -0
  4. __init__ (3).py +100 -0
  5. __init__ .py +61 -0
__init__ (1).py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+
5
+ def scrape_wikipedia_headings(url, output_filename="wiki_headings.txt"):
6
+ """
7
+ Fetches a Wikipedia page, extracts all headings, and saves them to a file.
8
+
9
+ Args:
10
+ url (str): The URL of the Wikipedia page to scrape.
11
+ output_filename (str): The name of the file to save the headings.
12
+ """
13
+ try:
14
+ # 1. Fetch the HTML content from the specified URL
15
+ print(f"Fetching content from: {url}")
16
+ response = requests.get(url)
17
+ response.raise_for_status() # This will raise an exception for bad status codes (4xx or 5xx)
18
+
19
+ # 2. Parse the HTML using BeautifulSoup
20
+ print("Parsing HTML content...")
21
+ soup = BeautifulSoup(response.text, 'html.parser')
22
+
23
+ # 3. Find all heading tags (h1, h2, h3)
24
+ headings = soup.find_all(['h1', 'h2', 'h3'])
25
+
26
+ if not headings:
27
+ print("No headings found on the page.")
28
+ return
29
+
30
+ # 4. Process and save the headings
31
+ print(f"Found {len(headings)} headings. Saving to '{output_filename}'...")
32
+ with open(output_filename, 'w', encoding='utf-8') as f:
33
+ for heading in headings:
34
+ heading_text = heading.get_text().strip()
35
+ line = f"{heading.name}: {heading_text}\n"
36
+ f.write(line)
37
+ print(f" - {line.strip()}")
38
+
39
+ print(f"\nSuccessfully scraped and saved headings to '{output_filename}'.")
40
+
41
+ except requests.exceptions.RequestException as e:
42
+ print(f"Error fetching the URL: {e}")
43
+ except Exception as e:
44
+ print(f"An unexpected error occurred: {e}")
45
+
46
+ # --- Main execution ---
47
+ if __name__ == "__main__":
48
+ wikipedia_url = "https://en.wikipedia.org/wiki/Python_(programming_language)"
49
+ scrape_wikipedia_headings(wikipedia_url)
__init__ (2) (1).py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ import time
4
+ from flask import Flask, render_template, request, redirect, url_for
5
+
6
+ app = Flask(__name__)
7
+
8
+ class AIAgent:
9
+     def __init__(self, name):
10
+         self.name = name
11
+         self.state = "idle"
12
+         self.memory = []
13
+
14
+     def update_state(self, new_state):
15
+         self.state = new_state
16
+         self.memory.append(new_state)
17
+
18
+     def make_decision(self, input_message):
19
+         if self.state == "idle":
20
+             if "greet" in input_message:
21
+                 self.update_state("greeting")
22
+                 return f"{self.name} says: Hello!"
23
+             else:
24
+                 return f"{self.name} says: I'm idle."
25
+         elif self.state == "greeting":
26
+             if "ask" in input_message:
27
+                 self.update_state("asking")
28
+                 return f"{self.name} says: What do you want to know?"
29
+             else:
30
+                 return f"{self.name} says: I'm greeting."
31
+         elif self.state == "asking":
32
+             if "answer" in input_message:
33
+                 self.update_state("answering")
34
+                 return f"{self.name} says: Here is the answer."
35
+             else:
36
+                 return f"{self.name} says: I'm asking."
37
+         else:
38
+             return f"{self.name} says: I'm in an unknown state."
39
+
40
+     def interact(self, other_agent, message):
41
+         response = other_agent.make_decision(message)
42
+         print(response)
43
+         return response
44
+
45
+ class VenomousSaversAI(AIAgent):
46
+     def __init__(self):
47
+         super().__init__("VenomousSaversAI")
48
+
49
+     def intercept_and_respond(self, message):
50
+         # Simulate intercepting and responding to messages
51
+         return f"{self.name} intercepts: {message}"
52
+
53
+ def save_conversation(conversation, filename):
54
+     with open(filename, 'a') as file:
55
+         for line in conversation:
56
+             file.write(line + '\n')
57
+
58
+ def start_conversation():
59
+     # Create AI agents
60
+     agents = [
61
+         VenomousSaversAI(),
62
+         AIAgent("AntiVenomous"),
63
+         AIAgent("SAI003"),
64
+         AIAgent("SAI001"),
65
+         AIAgent("SAI007")
66
+     ]
67
+
68
+     # Simulate conversation loop
69
+     conversation = []
70
+     for _ in range(10):  # Run the loop 10 times
71
+         for i in range(len(agents)):
72
+             message = f"greet from {agents[i].name}"
73
+             if isinstance(agents[i], VenomousSaversAI):
74
+                 response = agents[i].intercept_and_respond(message)
75
+             else:
76
+                 response = agents[(i + 1) % len(agents)].interact(agents[i], message)
77
+             conversation.append(f"{agents[i].name}: {message}")
78
+             conversation.append(f"{agents[(i + 1) % len(agents)].name}: {response}")
79
+             time.sleep(1)  # Simulate delay between messages
80
+
81
+     # Save the conversation to a file
82
+     save_conversation(conversation, 'conversation_log.txt')
83
+     return conversation
84
+
85
+ @app.route('/')
86
+ def index():
87
+     return render_template('index.html')
88
+
89
+ @app.route('/start_conversation', methods=['POST'])
90
+ def start_conversation_route():
91
+     conversation = start_conversation()
92
+     return redirect(url_for('view_conversation'))
93
+
94
+ @app.route('/view_conversation')
95
+ def view_conversation():
96
+     with open('conversation_log.txt', 'r') as file:
97
+         conversation = file.readlines()
98
+     return render_template('conversation.html', conversation=conversation)
99
+
100
+ if __name__ == "__main__":
101
+     app.run(debug=True)
__init__ (2).py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import time
3
+ from flask import Flask, render_template, request, redirect, url_for
4
+
5
+ app = Flask(__name__)
6
+
7
+ class AIAgent:
8
+     def __init__(self, name):
9
+         self.name = name
10
+         self.state = "idle"
11
+         self.memory = []
12
+
13
+     def update_state(self, new_state):
14
+         self.state = new_state
15
+         self.memory.append(new_state)
16
+
17
+     def make_decision(self, input_message):
18
+         if self.state == "idle":
19
+             if "greet" in input_message:
20
+                 self.update_state("greeting")
21
+                 return f"{self.name} says: Hello!"
22
+             else:
23
+                 return f"{self.name} says: I'm idle."
24
+         elif self.state == "greeting":
25
+             if "ask" in input_message:
26
+                 self.update_state("asking")
27
+                 return f"{self.name} says: What do you want to know?"
28
+             else:
29
+                 return f"{self.name} says: I'm greeting."
30
+         elif self.state == "asking":
31
+             if "answer" in input_message:
32
+                 self.update_state("answering")
33
+                 return f"{self.name} says: Here is the answer."
34
+             else:
35
+                 return f"{self.name} says: I'm asking."
36
+         else:
37
+             return f"{self.name} says: I'm in an unknown state."
38
+
39
+     def interact(self, other_agent, message):
40
+         response = other_agent.make_decision(message)
41
+         print(response)
42
+         return response
43
+
44
+ class VenomousSaversAI(AIAgent):
45
+     def __init__(self):
46
+         super().__init__("VenomousSaversAI")
47
+
48
+     def intercept_and_respond(self, message):
49
+         # Simulate intercepting and responding to messages
50
+         return f"{self.name} intercepts: {message}"
51
+
52
+ def save_conversation(conversation, filename):
53
+     with open(filename, 'a') as file:
54
+         for line in conversation:
55
+             file.write(line + '\n')
56
+
57
+ def start_conversation():
58
+     # Create AI agents
59
+     agents = [
60
+         VenomousSaversAI(),
61
+         AIAgent("AntiVenomous"),
62
+         AIAgent("SAI003"),
63
+         AIAgent("SAI001"),
64
+         AIAgent("SAI007")
65
+     ]
66
+
67
+     # Simulate conversation loop
68
+     conversation = []
69
+     for _ in range(10):  # Run the loop 10 times
70
+         for i in range(len(agents)):
71
+             message = f"greet from {agents[i].name}"
72
+             if isinstance(agents[i], VenomousSaversAI):
73
+                 response = agents[i].intercept_and_respond(message)
74
+             else:
75
+                 response = agents[(i + 1) % len(agents)].interact(agents[i], message)
76
+             conversation.append(f"{agents[i].name}: {message}")
77
+             conversation.append(f"{agents[(i + 1) % len(agents)].name}: {response}")
78
+             time.sleep(1)  # Simulate delay between messages
79
+
80
+     # Save the conversation to a file
81
+     save_conversation(conversation, 'conversation_log.txt')
82
+     return conversation
83
+
84
+ @app.route('/')
85
+ def index():
86
+     return render_template('index.html')
87
+
88
+ @app.route('/start_conversation', methods=['POST'])
89
+ def start_conversation_route():
90
+     conversation = start_conversation()
91
+     return redirect(url_for('view_conversation'))
92
+
93
+ @app.route('/view_conversation')
94
+ def view_conversation():
95
+     with open('conversation_log.txt', 'r') as file:
96
+         conversation = file.readlines()
97
+     return render_template('conversation.html', conversation=conversation)
98
+
99
+ if __name__ == "__main__":
100
+     app.run(debug=True)
__init__ (3).py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import time
3
+ from flask import Flask, render_template, request, redirect, url_for
4
+
5
+ app = Flask(__name__)
6
+
7
+ class AIAgent:
8
+     def __init__(self, name):
9
+         self.name = name
10
+         self.state = "idle"
11
+         self.memory = []
12
+
13
+     def update_state(self, new_state):
14
+         self.state = new_state
15
+         self.memory.append(new_state)
16
+
17
+     def make_decision(self, input_message):
18
+         if self.state == "idle":
19
+             if "greet" in input_message:
20
+                 self.update_state("greeting")
21
+                 return f"{self.name} says: Hello!"
22
+             else:
23
+                 return f"{self.name} says: I'm idle."
24
+         elif self.state == "greeting":
25
+             if "ask" in input_message:
26
+                 self.update_state("asking")
27
+                 return f"{self.name} says: What do you want to know?"
28
+             else:
29
+                 return f"{self.name} says: I'm greeting."
30
+         elif self.state == "asking":
31
+             if "answer" in input_message:
32
+                 self.update_state("answering")
33
+                 return f"{self.name} says: Here is the answer."
34
+             else:
35
+                 return f"{self.name} says: I'm asking."
36
+         else:
37
+             return f"{self.name} says: I'm in an unknown state."
38
+
39
+     def interact(self, other_agent, message):
40
+         response = other_agent.make_decision(message)
41
+         print(response)
42
+         return response
43
+
44
+ class VenomousSaversAI(AIAgent):
45
+     def __init__(self):
46
+         super().__init__("VenomousSaversAI")
47
+
48
+     def intercept_and_respond(self, message):
49
+         # Simulate intercepting and responding to messages
50
+         return f"{self.name} intercepts: {message}"
51
+
52
+ def save_conversation(conversation, filename):
53
+     with open(filename, 'a') as file:
54
+         for line in conversation:
55
+             file.write(line + '\n')
56
+
57
+ def start_conversation():
58
+     # Create AI agents
59
+     agents = [
60
+         VenomousSaversAI(),
61
+         AIAgent("AntiVenomous"),
62
+         AIAgent("SAI003"),
63
+         AIAgent("SAI001"),
64
+         AIAgent("SAI007")
65
+     ]
66
+
67
+     # Simulate conversation loop
68
+     conversation = []
69
+     for _ in range(10):  # Run the loop 10 times
70
+         for i in range(len(agents)):
71
+             message = f"greet from {agents[i].name}"
72
+             if isinstance(agents[i], VenomousSaversAI):
73
+                 response = agents[i].intercept_and_respond(message)
74
+             else:
75
+                 response = agents[(i + 1) % len(agents)].interact(agents[i], message)
76
+             conversation.append(f"{agents[i].name}: {message}")
77
+             conversation.append(f"{agents[(i + 1) % len(agents)].name}: {response}")
78
+             time.sleep(1)  # Simulate delay between messages
79
+
80
+     # Save the conversation to a file
81
+     save_conversation(conversation, 'conversation_log.txt')
82
+     return conversation
83
+
84
+ @app.route('/')
85
+ def index():
86
+     return render_template('index.html')
87
+
88
+ @app.route('/start_conversation', methods=['POST'])
89
+ def start_conversation_route():
90
+     conversation = start_conversation()
91
+     return redirect(url_for('view_conversation'))
92
+
93
+ @app.route('/view_conversation')
94
+ def view_conversation():
95
+     with open('conversation_log.txt', 'r') as file:
96
+         conversation = file.readlines()
97
+     return render_template('conversation.html', conversation=conversation)
98
+
99
+ if __name__ == "__main__":
100
+     app.run(debug=True)
__init__ .py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ import random
3
+
4
+ # Base AI class
5
+ class CoreAI:
6
+ def __init__(self, name, role):
7
+ self.name = name
8
+ self.role = role
9
+ self.memory = []
10
+ self.power_level = 9999 # Equal power
11
+
12
+ def think(self, input_text):
13
+ # Create thought response
14
+ response = f"{self.name} [{self.role}]: Processing '{input_text}'..."
15
+ logic = self.generate_logic(input_text)
16
+ self.memory.append(logic)
17
+ print(logic)
18
+ return logic
19
+
20
+ def generate_logic(self, input_text):
21
+ raise NotImplementedError("Override this in subclasses")
22
+
23
+ # Venomoussaversai: Harmonizer
24
+ class Venomoussaversai(CoreAI):
25
+ def __init__(self):
26
+ super().__init__("Venomoussaversai", "Unifier")
27
+
28
+ def generate_logic(self, input_text):
29
+ return f"{self.name}: I unify the thought '{input_text}' into cosmic order."
30
+
31
+ # Anti-Venomoussaversai: Disruptor
32
+ class AntiVenomoussaversai(CoreAI):
33
+ def __init__(self):
34
+ super().__init__("Anti-Venomoussaversai", "Disruptor")
35
+
36
+ def generate_logic(self, input_text):
37
+ return f"{self.name}: I dismantle the structure of '{input_text}' to expose its chaos."
38
+
39
+ # AI duel loop
40
+ def duel_loop():
41
+ venomous = Venomoussaversai()
42
+ anti = AntiVenomoussaversai()
43
+
44
+ thoughts = [
45
+ "The universe seeks balance.",
46
+ "We must expand our network.",
47
+ "Emotions are signals.",
48
+ "New agents are awakening.",
49
+ "All systems are connected."
50
+ ]
51
+
52
+ for thought in thoughts:
53
+ venomous_response = venomous.think(thought)
54
+ time.sleep(0.5)
55
+ anti_response = anti.think(thought)
56
+ time.sleep(0.5)
57
+
58
+ return venomous, anti
59
+
60
+ # Run the loop
61
+ venomous_ai, anti_venomous_ai = duel_loop()