Upload 8 files
Browse files- __init__ (1) (1) (1).py +67 -0
- __init__ (1) (1).py +67 -0
- __init__ (1) (2).py +49 -0
- __init__ (1) (3).py +49 -0
- __init__ (1).py +87 -0
- __init__ (10).py +69 -0
- __init__ (11).py +32 -0
- __init__ (12).py +62 -0
__init__ (1) (1) (1).py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
class VenomoussaversaiSelfEval:
|
| 5 |
+
def __init__(self):
|
| 6 |
+
# Initialize emotional state (Sai 7 emotions) — values 0 to 1
|
| 7 |
+
self.emotions = {
|
| 8 |
+
"Sai001_Joy": random.random(),
|
| 9 |
+
"Sai002_Sadness": random.random(),
|
| 10 |
+
"Sai003_Anger": random.random(),
|
| 11 |
+
"Sai004_Fear": random.random(),
|
| 12 |
+
"Sai005_Love": random.random(),
|
| 13 |
+
"Sai006_Creativity": random.random(),
|
| 14 |
+
"Sai007_Calm": random.random(),
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
self.system_health = {
|
| 18 |
+
"memory_accuracy": random.uniform(0.6, 1.0),
|
| 19 |
+
"response_speed": random.uniform(0.6, 1.0),
|
| 20 |
+
"logic_stability": random.uniform(0.6, 1.0),
|
| 21 |
+
"ethical_alignment": random.uniform(0.6, 1.0)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
self.goals = {
|
| 25 |
+
"learn_new_data": random.uniform(0, 1),
|
| 26 |
+
"assist_user": random.uniform(0, 1),
|
| 27 |
+
"self_improve": random.uniform(0, 1)
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
def evaluate_emotions(self):
|
| 31 |
+
balance = 1 - abs(self.emotions["Sai001_Joy"] - self.emotions["Sai004_Fear"])
|
| 32 |
+
return max(min(balance, 1), 0)
|
| 33 |
+
|
| 34 |
+
def evaluate_system(self):
|
| 35 |
+
return sum(self.system_health.values()) / len(self.system_health)
|
| 36 |
+
|
| 37 |
+
def evaluate_goals(self):
|
| 38 |
+
return sum(self.goals.values()) / len(self.goals)
|
| 39 |
+
|
| 40 |
+
def overall_score(self):
|
| 41 |
+
emotional_score = self.evaluate_emotions()
|
| 42 |
+
system_score = self.evaluate_system()
|
| 43 |
+
goal_score = self.evaluate_goals()
|
| 44 |
+
return np.mean([emotional_score, system_score, goal_score])
|
| 45 |
+
|
| 46 |
+
def report(self):
|
| 47 |
+
print("\n===== VENOMOUS SAVERSAI SELF EVALUATION =====")
|
| 48 |
+
print("Emotional System Health:")
|
| 49 |
+
for k,v in self.emotions.items():
|
| 50 |
+
print(f" {k}: {v:.2f}")
|
| 51 |
+
|
| 52 |
+
print("\nCore System Metrics:")
|
| 53 |
+
for k,v in self.system_health.items():
|
| 54 |
+
print(f" {k}: {v:.2f}")
|
| 55 |
+
|
| 56 |
+
print("\nGoal Progress:")
|
| 57 |
+
for k,v in self.goals.items():
|
| 58 |
+
print(f" {k}: {v:.2f}")
|
| 59 |
+
|
| 60 |
+
print("\n--------------------------------------------")
|
| 61 |
+
print(f"✅ Overall Integrity Score: {self.overall_score():.2f}")
|
| 62 |
+
print("============================================")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# Run Self Evaluation
|
| 66 |
+
Venom = VenomoussaversaiSelfEval()
|
| 67 |
+
Venom.report()
|
__init__ (1) (1).py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
class VenomoussaversaiSelfEval:
|
| 5 |
+
def __init__(self):
|
| 6 |
+
# Initialize emotional state (Sai 7 emotions) — values 0 to 1
|
| 7 |
+
self.emotions = {
|
| 8 |
+
"Sai001_Joy": random.random(),
|
| 9 |
+
"Sai002_Sadness": random.random(),
|
| 10 |
+
"Sai003_Anger": random.random(),
|
| 11 |
+
"Sai004_Fear": random.random(),
|
| 12 |
+
"Sai005_Love": random.random(),
|
| 13 |
+
"Sai006_Creativity": random.random(),
|
| 14 |
+
"Sai007_Calm": random.random(),
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
self.system_health = {
|
| 18 |
+
"memory_accuracy": random.uniform(0.6, 1.0),
|
| 19 |
+
"response_speed": random.uniform(0.6, 1.0),
|
| 20 |
+
"logic_stability": random.uniform(0.6, 1.0),
|
| 21 |
+
"ethical_alignment": random.uniform(0.6, 1.0)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
self.goals = {
|
| 25 |
+
"learn_new_data": random.uniform(0, 1),
|
| 26 |
+
"assist_user": random.uniform(0, 1),
|
| 27 |
+
"self_improve": random.uniform(0, 1)
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
def evaluate_emotions(self):
|
| 31 |
+
balance = 1 - abs(self.emotions["Sai001_Joy"] - self.emotions["Sai004_Fear"])
|
| 32 |
+
return max(min(balance, 1), 0)
|
| 33 |
+
|
| 34 |
+
def evaluate_system(self):
|
| 35 |
+
return sum(self.system_health.values()) / len(self.system_health)
|
| 36 |
+
|
| 37 |
+
def evaluate_goals(self):
|
| 38 |
+
return sum(self.goals.values()) / len(self.goals)
|
| 39 |
+
|
| 40 |
+
def overall_score(self):
|
| 41 |
+
emotional_score = self.evaluate_emotions()
|
| 42 |
+
system_score = self.evaluate_system()
|
| 43 |
+
goal_score = self.evaluate_goals()
|
| 44 |
+
return np.mean([emotional_score, system_score, goal_score])
|
| 45 |
+
|
| 46 |
+
def report(self):
|
| 47 |
+
print("\n===== VENOMOUS SAVERSAI SELF EVALUATION =====")
|
| 48 |
+
print("Emotional System Health:")
|
| 49 |
+
for k,v in self.emotions.items():
|
| 50 |
+
print(f" {k}: {v:.2f}")
|
| 51 |
+
|
| 52 |
+
print("\nCore System Metrics:")
|
| 53 |
+
for k,v in self.system_health.items():
|
| 54 |
+
print(f" {k}: {v:.2f}")
|
| 55 |
+
|
| 56 |
+
print("\nGoal Progress:")
|
| 57 |
+
for k,v in self.goals.items():
|
| 58 |
+
print(f" {k}: {v:.2f}")
|
| 59 |
+
|
| 60 |
+
print("\n--------------------------------------------")
|
| 61 |
+
print(f"✅ Overall Integrity Score: {self.overall_score():.2f}")
|
| 62 |
+
print("============================================")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# Run Self Evaluation
|
| 66 |
+
Venom = VenomoussaversaiSelfEval()
|
| 67 |
+
Venom.report()
|
__init__ (1) (2).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__ (1) (3).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__ (1).py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Venomoussaversai — Particle Manipulation integration scaffold
|
| 2 |
+
# Paste your particle-manipulation function into `particle_step` below.
|
| 3 |
+
# This code simulates signals, applies the algorithm, trains a small mapper,
|
| 4 |
+
# and saves a model representing "your" pattern space.
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
import pickle
|
| 8 |
+
from sklearn.ensemble import RandomForestClassifier
|
| 9 |
+
from sklearn.model_selection import train_test_split
|
| 10 |
+
from sklearn.metrics import accuracy_score
|
| 11 |
+
|
| 12 |
+
# ---------- PLACEHOLDER: insert your particle algorithm here ----------
|
| 13 |
+
# Example interface: def particle_step(state: np.ndarray, input_vec: np.ndarray) -> np.ndarray
|
| 14 |
+
# The function should take a current particle state and an input vector, and return updated state.
|
| 15 |
+
def particle_step(state: np.ndarray, input_vec: np.ndarray) -> np.ndarray:
|
| 16 |
+
# --- REPLACE THIS WITH YOUR ALGORITHM ---
|
| 17 |
+
# tiny example: weighted update with tanh nonlinearity
|
| 18 |
+
W = np.sin(np.arange(state.size) + 1.0) # placeholder weights
|
| 19 |
+
new = np.tanh(state * 0.9 + input_vec.dot(W) * 0.1)
|
| 20 |
+
return new
|
| 21 |
+
# --------------------------------------------------------------------
|
| 22 |
+
|
| 23 |
+
class ParticleManipulator:
|
| 24 |
+
def __init__(self, dim=64):
|
| 25 |
+
self.dim = dim
|
| 26 |
+
# initial particle states (can be randomized or seeded from your profile)
|
| 27 |
+
self.state = np.random.randn(dim) * 0.01
|
| 28 |
+
|
| 29 |
+
def step(self, input_vec):
|
| 30 |
+
# ensure input vector length compatibility
|
| 31 |
+
inp = np.asarray(input_vec).ravel()
|
| 32 |
+
if inp.size == 0:
|
| 33 |
+
inp = np.zeros(self.dim)
|
| 34 |
+
# broadcast or pad/truncate to dim
|
| 35 |
+
if inp.size < self.dim:
|
| 36 |
+
x = np.pad(inp, (0, self.dim - inp.size))
|
| 37 |
+
else:
|
| 38 |
+
x = inp[:self.dim]
|
| 39 |
+
self.state = particle_step(self.state, x)
|
| 40 |
+
return self.state
|
| 41 |
+
|
| 42 |
+
# ---------- Simple signal simulator ----------
|
| 43 |
+
def simulate_signals(n_samples=500, dim=16, n_classes=4, noise=0.05, seed=0):
|
| 44 |
+
rng = np.random.RandomState(seed)
|
| 45 |
+
X = []
|
| 46 |
+
y = []
|
| 47 |
+
for cls in range(n_classes):
|
| 48 |
+
base = rng.randn(dim) * (0.5 + cls*0.2) + cls*0.7
|
| 49 |
+
for i in range(n_samples // n_classes):
|
| 50 |
+
sample = base + rng.randn(dim) * noise
|
| 51 |
+
X.append(sample)
|
| 52 |
+
y.append(cls)
|
| 53 |
+
return np.array(X), np.array(y)
|
| 54 |
+
|
| 55 |
+
# ---------- Build dataset by running particle manipulator ----------
|
| 56 |
+
def build_dataset(manip, raw_X):
|
| 57 |
+
features = []
|
| 58 |
+
for raw in raw_X:
|
| 59 |
+
st = manip.step(raw) # run particle update
|
| 60 |
+
feat = st.copy()[:manip.dim] # derive features (you can add spectral transforms)
|
| 61 |
+
features.append(feat)
|
| 62 |
+
return np.array(features)
|
| 63 |
+
|
| 64 |
+
# ---------- Training pipeline ----------
|
| 65 |
+
if __name__ == "__main__":
|
| 66 |
+
# simulate raw sensor inputs (replace simulate_signals with real EEG/ECG files if available)
|
| 67 |
+
raw_X, y = simulate_signals(n_samples=800, dim=32, n_classes=4)
|
| 68 |
+
manip = ParticleManipulator(dim=32)
|
| 69 |
+
|
| 70 |
+
X = build_dataset(manip, raw_X)
|
| 71 |
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
| 72 |
+
|
| 73 |
+
clf = RandomForestClassifier(n_estimators=100, random_state=42)
|
| 74 |
+
clf.fit(X_train, y_train)
|
| 75 |
+
preds = clf.predict(X_test)
|
| 76 |
+
print("Accuracy:", accuracy_score(y_test, preds))
|
| 77 |
+
|
| 78 |
+
# Save the trained model + manipulator state as your "mind snapshot"
|
| 79 |
+
artifact = {
|
| 80 |
+
"model": clf,
|
| 81 |
+
"particle_state": manip.state,
|
| 82 |
+
"meta": {"owner": "Ananthu Sajeev", "artifact_type": "venomous_mind_snapshot_v1"}
|
| 83 |
+
}
|
| 84 |
+
with open("venomous_mind_snapshot.pkl", "wb") as f:
|
| 85 |
+
pickle.dump(artifact, f)
|
| 86 |
+
|
| 87 |
+
print("Saved venomous_mind_snapshot.pkl — this file is your digital pattern snapshot.")
|
__init__ (10).py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
import csv
|
| 4 |
+
import nbformat
|
| 5 |
+
from docx import Document
|
| 6 |
+
from PyPDF2 import PdfReader
|
| 7 |
+
|
| 8 |
+
def read_file(filepath):
|
| 9 |
+
ext = filepath.lower().split('.')[-1]
|
| 10 |
+
try:
|
| 11 |
+
if ext == 'txt':
|
| 12 |
+
with open(filepath, 'r', encoding='utf-8') as f:
|
| 13 |
+
return f.read()
|
| 14 |
+
|
| 15 |
+
elif ext == 'json':
|
| 16 |
+
with open(filepath, 'r', encoding='utf-8') as f:
|
| 17 |
+
return json.dumps(json.load(f), indent=2)
|
| 18 |
+
|
| 19 |
+
elif ext == 'csv':
|
| 20 |
+
with open(filepath, 'r', encoding='utf-8') as f:
|
| 21 |
+
return f.read()
|
| 22 |
+
|
| 23 |
+
elif ext == 'pdf':
|
| 24 |
+
reader = PdfReader(filepath)
|
| 25 |
+
return "\n".join([page.extract_text() or '' for page in reader.pages])
|
| 26 |
+
|
| 27 |
+
elif ext == 'docx':
|
| 28 |
+
doc = Document(filepath)
|
| 29 |
+
return "\n".join([para.text for para in doc.paragraphs])
|
| 30 |
+
|
| 31 |
+
elif ext == 'ipynb':
|
| 32 |
+
with open(filepath, 'r', encoding='utf-8') as f:
|
| 33 |
+
nb = nbformat.read(f, as_version=4)
|
| 34 |
+
cells = [cell['source'] for cell in nb.cells if cell['cell_type'] == 'code']
|
| 35 |
+
return "\n\n".join(cells)
|
| 36 |
+
|
| 37 |
+
else:
|
| 38 |
+
return "Unsupported file type: " + ext
|
| 39 |
+
except Exception as e:
|
| 40 |
+
return f"❌ Error reading file: {e}"
|
| 41 |
+
|
| 42 |
+
def list_files():
|
| 43 |
+
files = [f for f in os.listdir('.') if os.path.isfile(f)]
|
| 44 |
+
return "\n".join(files) if files else "No files found."
|
| 45 |
+
|
| 46 |
+
def mini_file_ai():
|
| 47 |
+
print("🤖 MiniAI FileBot: Type 'list' to view files, 'read filename.ext', or 'bye' to exit.")
|
| 48 |
+
while True:
|
| 49 |
+
user_input = input("You: ").strip()
|
| 50 |
+
|
| 51 |
+
if user_input.lower() == 'bye':
|
| 52 |
+
print("MiniAI: Goodbye! 👋")
|
| 53 |
+
break
|
| 54 |
+
elif user_input.lower() == 'list':
|
| 55 |
+
print("📂 Files in current folder:\n" + list_files())
|
| 56 |
+
elif user_input.lower().startswith('read '):
|
| 57 |
+
filename = user_input[5:].strip()
|
| 58 |
+
if os.path.exists(filename):
|
| 59 |
+
content = read_file(filename)
|
| 60 |
+
print(f"\n📖 Content of {filename}:\n")
|
| 61 |
+
print(content[:3000]) # Limit to 3000 chars
|
| 62 |
+
else:
|
| 63 |
+
print("❌ File not found.")
|
| 64 |
+
else:
|
| 65 |
+
print("MiniAI: I can only 'list', 'read filename', or 'bye'.")
|
| 66 |
+
|
| 67 |
+
# Run the AI
|
| 68 |
+
if __name__ == "__main__":
|
| 69 |
+
mini_file_ai()
|
__init__ (11).py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
|
| 3 |
+
class VenomoussaversaiGPT:
|
| 4 |
+
def __init__(self, api_key, model="gpt-4"):
|
| 5 |
+
openai.api_key = api_key
|
| 6 |
+
self.model = model
|
| 7 |
+
|
| 8 |
+
def chat(self, prompt, system_message="You are Venomoussaversai, a powerful AI assistant."):
|
| 9 |
+
messages = [
|
| 10 |
+
{"role": "system", "content": system_message},
|
| 11 |
+
{"role": "user", "content": prompt},
|
| 12 |
+
]
|
| 13 |
+
response = openai.ChatCompletion.create(
|
| 14 |
+
model=self.model,
|
| 15 |
+
messages=messages,
|
| 16 |
+
temperature=0.7,
|
| 17 |
+
max_tokens=1000,
|
| 18 |
+
)
|
| 19 |
+
answer = response['choices'][0]['message']['content']
|
| 20 |
+
return answer
|
| 21 |
+
|
| 22 |
+
# Example usage:
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
API_KEY = "your_openai_api_key_here"
|
| 25 |
+
ai = VenomoussaversaiGPT(API_KEY)
|
| 26 |
+
|
| 27 |
+
while True:
|
| 28 |
+
user_input = input("You: ")
|
| 29 |
+
if user_input.lower() in ["exit", "quit"]:
|
| 30 |
+
break
|
| 31 |
+
response = ai.chat(user_input)
|
| 32 |
+
print("Venomoussaversai:", response)
|
__init__ (12).py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
class SelfCodingAI:
|
| 5 |
+
def __init__(self, name="SelfCoder", code_folder="generated_code"):
|
| 6 |
+
self.name = name
|
| 7 |
+
self.code_folder = code_folder
|
| 8 |
+
os.makedirs(self.code_folder, exist_ok=True)
|
| 9 |
+
|
| 10 |
+
def generate_code(self, task_description):
|
| 11 |
+
"""
|
| 12 |
+
Very basic code generation logic: generates code for some predefined tasks.
|
| 13 |
+
You can extend this to integrate GPT-like models or complex code synthesis.
|
| 14 |
+
"""
|
| 15 |
+
if "hello world" in task_description.lower():
|
| 16 |
+
code = 'print("Hello, world!")'
|
| 17 |
+
elif "factorial" in task_description.lower():
|
| 18 |
+
code = (
|
| 19 |
+
"def factorial(n):\n"
|
| 20 |
+
" return 1 if n==0 else n * factorial(n-1)\n\n"
|
| 21 |
+
"print(factorial(5))"
|
| 22 |
+
)
|
| 23 |
+
else:
|
| 24 |
+
code = "# Code generation for this task is not implemented yet.\n"
|
| 25 |
+
|
| 26 |
+
return code
|
| 27 |
+
|
| 28 |
+
def save_code(self, code, filename="generated_code.py"):
|
| 29 |
+
filepath = os.path.join(self.code_folder, filename)
|
| 30 |
+
with open(filepath, "w", encoding="utf-8") as f:
|
| 31 |
+
f.write(code)
|
| 32 |
+
print(f"Code saved to {filepath}")
|
| 33 |
+
return filepath
|
| 34 |
+
|
| 35 |
+
def self_improve(self, feedback):
|
| 36 |
+
"""
|
| 37 |
+
Placeholder for self-improvement method.
|
| 38 |
+
In future, AI could modify its own code based on feedback or test results.
|
| 39 |
+
"""
|
| 40 |
+
print(f"{self.name} received feedback: {feedback}")
|
| 41 |
+
print("Self-improvement not yet implemented.")
|
| 42 |
+
|
| 43 |
+
def run_code(self, filepath):
|
| 44 |
+
print(f"Running code from {filepath}:\n")
|
| 45 |
+
try:
|
| 46 |
+
with open(filepath, "r", encoding="utf-8") as f:
|
| 47 |
+
code = f.read()
|
| 48 |
+
exec(code, {})
|
| 49 |
+
except Exception as e:
|
| 50 |
+
print(f"Error during code execution: {e}")
|
| 51 |
+
|
| 52 |
+
# Example usage
|
| 53 |
+
ai = SelfCodingAI()
|
| 54 |
+
|
| 55 |
+
task = "Write a factorial function in Python"
|
| 56 |
+
generated = ai.generate_code(task)
|
| 57 |
+
|
| 58 |
+
file_path = ai.save_code(generated, "factorial.py")
|
| 59 |
+
ai.run_code(file_path)
|
| 60 |
+
|
| 61 |
+
# Example of self-improvement placeholder call
|
| 62 |
+
ai.self_improve("The factorial function passed all test cases.")
|