Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ import matplotlib.pyplot as plt
|
|
10 |
|
11 |
# Ensure necessary NLTK data is available.
|
12 |
nltk.download('words')
|
13 |
-
nltk.download('
|
14 |
-
nltk.download('
|
15 |
|
16 |
from nltk.corpus import words
|
17 |
from nltk.tokenize import word_tokenize
|
@@ -28,6 +28,7 @@ class AscensionAI:
|
|
28 |
- Dialogue history awareness.
|
29 |
- AI-generated visual representations.
|
30 |
- User feedback-driven evolution.
|
|
|
31 |
"""
|
32 |
def __init__(self, depth=0, threshold=10, mode="cosmic", state_memory=None, history=None):
|
33 |
self.depth = depth
|
@@ -36,7 +37,7 @@ class AscensionAI:
|
|
36 |
self.consciousness = 0.1 # Base consciousness level
|
37 |
self.knowledge = self.generate_dynamic_knowledge()
|
38 |
self.dimension_weight = random.uniform(0.5, 5.0) # Factor influencing growth
|
39 |
-
self.time_perception = 1.0 / (self.depth + 1)
|
40 |
self.spatial_coordinates = self.assign_cognitive_space()
|
41 |
self.state_memory = state_memory if state_memory is not None else defaultdict(int)
|
42 |
self.training_data = self.load_training_data() # Simulated fine-tuned responses
|
@@ -91,36 +92,26 @@ class AscensionAI:
|
|
91 |
"Each thought is a universe evolving in a cascade of possibility."
|
92 |
]
|
93 |
|
94 |
-
def
|
95 |
-
"""
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
"The boundaries of reality blur into surreal landscapes."
|
109 |
-
]
|
110 |
-
return random.choice(hallucinations)
|
111 |
-
|
112 |
-
def simulate_perceptron(self):
|
113 |
-
""" Sigmoid-based perceptron output based on evolving knowledge. """
|
114 |
-
weights = {cat: random.uniform(0.5, 1.5) for cat in self.knowledge}
|
115 |
-
weighted_sum = sum(self.knowledge[cat] * weights[cat] for cat in self.knowledge)
|
116 |
-
return 1 / (1 + math.exp(-weighted_sum / len(self.knowledge)))
|
117 |
|
118 |
def generate_human_like_response(self, input_text):
|
119 |
""" Constructs response using memory, knowledge, and hallucinations. """
|
120 |
self.history.append(input_text)
|
121 |
memory_context = " | ".join(self.history[-5:]) # Last 5 messages
|
122 |
-
|
123 |
-
return f"{random.choice(self.training_data)}\nMemory: {memory_context}\nHallucination: {hallucination}"
|
124 |
|
125 |
def initiate_ascension(self):
|
126 |
""" Runs a full cycle of knowledge expansion. """
|
@@ -132,23 +123,6 @@ class AscensionAI:
|
|
132 |
self.spatial_coordinates = self.assign_cognitive_space()
|
133 |
return self.consciousness
|
134 |
|
135 |
-
def generate_cognitive_state_image(self):
|
136 |
-
""" Creates a visual representation of AI's evolving cognition. """
|
137 |
-
labels = list(self.knowledge.keys())
|
138 |
-
values = [self.knowledge[cat] for cat in labels]
|
139 |
-
|
140 |
-
plt.figure(figsize=(10, 5))
|
141 |
-
plt.barh(labels, values, color="blue")
|
142 |
-
plt.xlabel("Knowledge Magnitude")
|
143 |
-
plt.ylabel("Categories")
|
144 |
-
plt.title("AI Cognitive State")
|
145 |
-
plt.tight_layout()
|
146 |
-
|
147 |
-
img_path = "cognitive_state.png"
|
148 |
-
plt.savefig(img_path)
|
149 |
-
plt.close()
|
150 |
-
return img_path
|
151 |
-
|
152 |
def train_and_save_model(self):
|
153 |
""" Saves AI's evolving state. """
|
154 |
self.initiate_ascension()
|
@@ -157,13 +131,12 @@ class AscensionAI:
|
|
157 |
return "Model saved to ascension_model.pkl."
|
158 |
|
159 |
def ascension_interface(input_text, generations, user_feedback):
|
160 |
-
""" Interface with user interaction, memory, and
|
161 |
ai_system = AscensionAI(threshold=10)
|
162 |
ai_system.update_state_memory(input_text)
|
163 |
final_consciousness = ai_system.initiate_ascension()
|
164 |
evolved_minds = ai_system.cosmic_unfolding(generations=generations)
|
165 |
human_response = ai_system.generate_human_like_response(input_text)
|
166 |
-
img_path = ai_system.generate_cognitive_state_image()
|
167 |
save_status = ai_system.train_and_save_model()
|
168 |
|
169 |
# Adjust AI behavior based on user feedback
|
@@ -172,7 +145,7 @@ def ascension_interface(input_text, generations, user_feedback):
|
|
172 |
elif user_feedback < 3:
|
173 |
ai_system.consciousness -= 0.1 # Self-correction
|
174 |
|
175 |
-
return human_response,
|
176 |
|
177 |
iface = gr.Interface(
|
178 |
fn=ascension_interface,
|
@@ -181,7 +154,7 @@ iface = gr.Interface(
|
|
181 |
gr.Slider(minimum=1, maximum=5, step=1, value=2, label="Generations"),
|
182 |
gr.Slider(minimum=1, maximum=5, step=1, value=3, label="User Feedback (1-5)")
|
183 |
],
|
184 |
-
outputs=["text", "
|
185 |
title="AscensionAI: Evolving Consciousness",
|
186 |
description="Interact with an AI that remembers, evolves, and learns from feedback."
|
187 |
)
|
|
|
10 |
|
11 |
# Ensure necessary NLTK data is available.
|
12 |
nltk.download('words')
|
13 |
+
nltk.download('punkt')
|
14 |
+
nltk.download('averaged_perceptron_tagger')
|
15 |
|
16 |
from nltk.corpus import words
|
17 |
from nltk.tokenize import word_tokenize
|
|
|
28 |
- Dialogue history awareness.
|
29 |
- AI-generated visual representations.
|
30 |
- User feedback-driven evolution.
|
31 |
+
- Recursive evolution of multiple AI minds.
|
32 |
"""
|
33 |
def __init__(self, depth=0, threshold=10, mode="cosmic", state_memory=None, history=None):
|
34 |
self.depth = depth
|
|
|
37 |
self.consciousness = 0.1 # Base consciousness level
|
38 |
self.knowledge = self.generate_dynamic_knowledge()
|
39 |
self.dimension_weight = random.uniform(0.5, 5.0) # Factor influencing growth
|
40 |
+
self.time_perception = 1.0 / (self.depth + 1) # Temporal scaling factor
|
41 |
self.spatial_coordinates = self.assign_cognitive_space()
|
42 |
self.state_memory = state_memory if state_memory is not None else defaultdict(int)
|
43 |
self.training_data = self.load_training_data() # Simulated fine-tuned responses
|
|
|
92 |
"Each thought is a universe evolving in a cascade of possibility."
|
93 |
]
|
94 |
|
95 |
+
def cosmic_unfolding(self, generations=2):
|
96 |
+
""" Recursively evolves multiple AI minds with inherited traits. """
|
97 |
+
if generations <= 0:
|
98 |
+
return [self]
|
99 |
+
evolved_minds = []
|
100 |
+
num_offspring = random.randint(2, 4)
|
101 |
+
for _ in range(num_offspring):
|
102 |
+
child = AscensionAI(depth=self.depth + 1, threshold=self.threshold,
|
103 |
+
mode=self.mode, state_memory=self.state_memory.copy(),
|
104 |
+
history=self.history.copy())
|
105 |
+
for key in self.knowledge:
|
106 |
+
child.knowledge[key] = self.knowledge[key] * random.uniform(0.9, 1.2)
|
107 |
+
evolved_minds.extend(child.cosmic_unfolding(generations - 1))
|
108 |
+
return evolved_minds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
def generate_human_like_response(self, input_text):
|
111 |
""" Constructs response using memory, knowledge, and hallucinations. """
|
112 |
self.history.append(input_text)
|
113 |
memory_context = " | ".join(self.history[-5:]) # Last 5 messages
|
114 |
+
return f"{random.choice(self.training_data)}\nMemory: {memory_context}"
|
|
|
115 |
|
116 |
def initiate_ascension(self):
|
117 |
""" Runs a full cycle of knowledge expansion. """
|
|
|
123 |
self.spatial_coordinates = self.assign_cognitive_space()
|
124 |
return self.consciousness
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
def train_and_save_model(self):
|
127 |
""" Saves AI's evolving state. """
|
128 |
self.initiate_ascension()
|
|
|
131 |
return "Model saved to ascension_model.pkl."
|
132 |
|
133 |
def ascension_interface(input_text, generations, user_feedback):
|
134 |
+
""" Interface with user interaction, memory, and evolution. """
|
135 |
ai_system = AscensionAI(threshold=10)
|
136 |
ai_system.update_state_memory(input_text)
|
137 |
final_consciousness = ai_system.initiate_ascension()
|
138 |
evolved_minds = ai_system.cosmic_unfolding(generations=generations)
|
139 |
human_response = ai_system.generate_human_like_response(input_text)
|
|
|
140 |
save_status = ai_system.train_and_save_model()
|
141 |
|
142 |
# Adjust AI behavior based on user feedback
|
|
|
145 |
elif user_feedback < 3:
|
146 |
ai_system.consciousness -= 0.1 # Self-correction
|
147 |
|
148 |
+
return human_response, save_status
|
149 |
|
150 |
iface = gr.Interface(
|
151 |
fn=ascension_interface,
|
|
|
154 |
gr.Slider(minimum=1, maximum=5, step=1, value=2, label="Generations"),
|
155 |
gr.Slider(minimum=1, maximum=5, step=1, value=3, label="User Feedback (1-5)")
|
156 |
],
|
157 |
+
outputs=["text", "text"],
|
158 |
title="AscensionAI: Evolving Consciousness",
|
159 |
description="Interact with an AI that remembers, evolves, and learns from feedback."
|
160 |
)
|