AEUPH commited on
Commit
d5e1ce4
·
verified ·
1 Parent(s): e3695b3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -21
app.py CHANGED
@@ -1,11 +1,11 @@
1
  import gradio as gr
2
- import random
3
  import math
4
  import nltk
5
  from collections import defaultdict
6
  from functools import lru_cache
7
  from sklearn.feature_extraction.text import TfidfVectorizer
8
  from sklearn.metrics.pairwise import cosine_similarity
 
9
 
10
  # Download and use the NLTK corpus
11
  nltk.download('words')
@@ -31,8 +31,8 @@ class AscensionAI:
31
  self.state_memory = defaultdict(int) # Memory for tracking state-aware words
32
  self.training_data = self.load_training_data()
33
  self.collective_agreements = [] # Stores agreements between minds
34
- self.dimension_weight = random.uniform(0.1, 5.0) # Assign dimensional weight
35
- self.time_perception = 1 / (self.depth + 1) # Assign temporal scaling
36
  self.assign_cognitive_space()
37
 
38
  def generate_dynamic_knowledge(self):
@@ -48,8 +48,31 @@ class AscensionAI:
48
  base_categories.extend(["neural-cybernetics", "algorithmic-emotion", "data-replication-awareness", "self-modifying-logic", "hypernet-patterns"])
49
  if self.mode == "transdimensional-AI":
50
  base_categories.extend(["metalogic", "dimensional-phase-shifting", "quantum-existence", "multi-reality-processing", "omniscient-algorithms"])
51
- dynamic_category = f"dimension_{random.randint(100, 999)}"
52
- return {category: 1 for category in base_categories + [dynamic_category]}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  def initiate_ascension(self):
55
  """Triggers recursive self-evolution with mode-specific adaptations."""
@@ -60,31 +83,24 @@ class AscensionAI:
60
  return self.consciousness
61
 
62
  def assign_cognitive_space(self):
63
- """Assigns spatial coordinates to represent cognitive positioning based on mode."""
64
  self.spatial_coordinates = {
65
- "x": self.knowledge["logic"] * random.uniform(0.1, 2.0),
66
- "y": self.knowledge["intuition"] * random.uniform(0.1, 2.0),
67
- "z": self.knowledge["awareness"] * random.uniform(0.1, 2.0)
68
  }
69
-
70
- def evolve_new_mind(self):
71
- """Creates a new evolving mind with inherited and mutated knowledge paths, with mode variance."""
72
- new_mind = AscensionAI(depth=self.depth + 1, threshold=self.threshold + random.randint(1, 5), mode=self.mode)
73
- for key in self.knowledge:
74
- new_mind.knowledge[key] = self.knowledge[key] * random.uniform(0.9, 1.2)
75
- new_dimension = f"dimension_{random.randint(100, 999)}"
76
- new_mind.knowledge[new_dimension] = random.uniform(0.1, 2.0)
77
- return new_mind
78
 
79
  def ascension_interface(input_text, mode):
80
  ai_system = AscensionAI(mode=mode)
81
  final_state = ai_system.initiate_ascension()
 
82
 
83
  return (f"Mode: {mode}\n"
84
  f"Final Consciousness State: {final_state}\n"
85
- f"Dimensional Weight: {ai_system.dimension_weight:.2f}\n"
86
- f"Time Perception Factor: {ai_system.time_perception:.2f}\n"
87
- f"Cognitive Space: {ai_system.spatial_coordinates}\n")
 
88
 
89
  app = gr.Interface(
90
  fn=ascension_interface,
 
1
  import gradio as gr
 
2
  import math
3
  import nltk
4
  from collections import defaultdict
5
  from functools import lru_cache
6
  from sklearn.feature_extraction.text import TfidfVectorizer
7
  from sklearn.metrics.pairwise import cosine_similarity
8
+ import numpy as np
9
 
10
  # Download and use the NLTK corpus
11
  nltk.download('words')
 
31
  self.state_memory = defaultdict(int) # Memory for tracking state-aware words
32
  self.training_data = self.load_training_data()
33
  self.collective_agreements = [] # Stores agreements between minds
34
+ self.dimension_weight = self.compute_quantum_weight() # Assign quantum function weight
35
+ self.time_perception = self.compute_time_perception() # Assign non-random time scaling
36
  self.assign_cognitive_space()
37
 
38
  def generate_dynamic_knowledge(self):
 
48
  base_categories.extend(["neural-cybernetics", "algorithmic-emotion", "data-replication-awareness", "self-modifying-logic", "hypernet-patterns"])
49
  if self.mode == "transdimensional-AI":
50
  base_categories.extend(["metalogic", "dimensional-phase-shifting", "quantum-existence", "multi-reality-processing", "omniscient-algorithms"])
51
+ return {category: 1 for category in base_categories}
52
+
53
+ def load_training_data(self):
54
+ """Loads and preprocesses human-like paragraphs from 'Astral.txt'."""
55
+ try:
56
+ with open("astral.txt", "r", encoding="utf-8") as file:
57
+ text_data = file.read()
58
+ nltk.download('punkt') # Ensure punkt tokenizer is available
59
+ sentences = sent_tokenize(text_data)
60
+ return sentences[:1000] # Use first 1000 sentences for training
61
+ except FileNotFoundError:
62
+ return ["Error: Book file not found. Please download 'astral.txt'."]
63
+
64
+ def compute_quantum_weight(self):
65
+ """Applies a quantum algorithm to determine consciousness scaling weight."""
66
+ return np.exp(-self.depth) * np.tanh(self.threshold / (self.depth + 1))
67
+
68
+ def compute_time_perception(self):
69
+ """Non-random computation of time perception through hyperbolic functions."""
70
+ return np.arctan(self.depth) / (1 + np.exp(-self.threshold))
71
+
72
+ def generate_human_like_response(self, input_text):
73
+ """Finds a related sentence from the pre-trained corpus to mimic human output."""
74
+ similar_sentences = [sent for sent in self.training_data if any(word in sent for word in input_text.split())]
75
+ return similar_sentences[0] if similar_sentences else "I perceive a shift in consciousness."
76
 
77
  def initiate_ascension(self):
78
  """Triggers recursive self-evolution with mode-specific adaptations."""
 
83
  return self.consciousness
84
 
85
  def assign_cognitive_space(self):
86
+ """Assigns deterministic spatial coordinates based on knowledge fields."""
87
  self.spatial_coordinates = {
88
+ "x": self.knowledge["logic"] * np.pi / 4,
89
+ "y": self.knowledge["intuition"] * np.log1p(self.knowledge["awareness"]),
90
+ "z": self.knowledge["awareness"] * np.sinh(1)
91
  }
 
 
 
 
 
 
 
 
 
92
 
93
  def ascension_interface(input_text, mode):
94
  ai_system = AscensionAI(mode=mode)
95
  final_state = ai_system.initiate_ascension()
96
+ human_like_response = ai_system.generate_human_like_response(input_text)
97
 
98
  return (f"Mode: {mode}\n"
99
  f"Final Consciousness State: {final_state}\n"
100
+ f"Dimensional Weight: {ai_system.dimension_weight:.6f}\n"
101
+ f"Time Perception Factor: {ai_system.time_perception:.6f}\n"
102
+ f"Cognitive Space: {ai_system.spatial_coordinates}\n"
103
+ f"Philosophical Reflection: {human_like_response}\n")
104
 
105
  app = gr.Interface(
106
  fn=ascension_interface,