awacke1 commited on
Commit
3d67fb6
·
verified ·
1 Parent(s): f1d5ff6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -28
app.py CHANGED
@@ -3,7 +3,7 @@ import os
3
  import json
4
  from PIL import Image
5
 
6
- # Set page configuration with a title and favicon
7
  st.set_page_config(
8
  page_title="🌌🚀ReMixable-AI-AR",
9
  page_icon="🌠",
@@ -15,8 +15,6 @@ st.set_page_config(
15
  'About': "# Midjourney: https://discord.com/channels/@me/997514686608191558"
16
  }
17
  )
18
-
19
- # Transhuman Space glossary with full content
20
  transhuman_glossary = {
21
  "🚀 Core Technologies": ["Nanotechnology🔬", "Artificial Intelligence🤖", "Quantum Computing💻", "Spacecraft Engineering🛸", "Biotechnology🧬", "Cybernetics🦾", "Virtual Reality🕶️", "Energy Systems⚡", "Material Science🧪", "Communication Technologies📡"],
22
  "🌐 Nations": ["Terran Federation🌍", "Martian Syndicate🔴", "Jovian Republics🪐", "Asteroid Belt Communities🌌", "Venusian Colonies🌋", "Lunar States🌖", "Outer System Alliances✨", "Digital Consciousness Collectives🧠", "Transhumanist Enclaves🦿", "Non-Human Intelligence Tribes👽"],
@@ -29,15 +27,12 @@ transhuman_glossary = {
29
  "👽 Terrorists": ["Bioengineered Virus Spreaders🧬💉", "Nanotechnology Saboteurs🔬🧨", "Cyber Terrorist Networks💻🔥", "Rogue AI Sects🤖🛑", "Space Anarchist Cells🚀Ⓐ", "Quantum Data Hijackers💻🔓", "Environmental Extremists🌍💣", "Technological Singularity Cults🤖🙏", "Interspecies Supremacists👽👑", "Orbital Bombardment Threats🛰️💥"],
30
  }
31
 
32
- # Ensure the directory for storing scores exists
 
33
  score_dir = "scores"
34
  os.makedirs(score_dir, exist_ok=True)
35
-
36
- # Function to generate a unique key for each button, including an emoji
37
  def generate_key(label, header, idx):
38
  return f"{header}_{label}_{idx}_key"
39
-
40
- # Function to increment and save score
41
  def update_score(key, increment=1):
42
  score_file = os.path.join(score_dir, f"{key}.json")
43
  if os.path.exists(score_file):
@@ -45,16 +40,11 @@ def update_score(key, increment=1):
45
  score_data = json.load(file)
46
  else:
47
  score_data = {"clicks": 0, "score": 0}
48
-
49
  score_data["clicks"] += 1
50
  score_data["score"] += increment
51
-
52
  with open(score_file, "w") as file:
53
  json.dump(score_data, file)
54
-
55
  return score_data["score"]
56
-
57
- # Function to load score
58
  def load_score(key):
59
  score_file = os.path.join(score_dir, f"{key}.json")
60
  if os.path.exists(score_file):
@@ -65,7 +55,7 @@ def load_score(key):
65
 
66
 
67
 
68
- # Function to search glossary and display results
69
  def search_glossary(query):
70
  for category, terms in transhuman_glossary.items():
71
  if query.lower() in (term.lower() for term in terms):
@@ -88,12 +78,14 @@ def search_glossary(query):
88
  # ------------------------------------------------------------------------------------------------
89
 
90
 
91
- # Display the glossary with Streamlit components, ensuring emojis are used
92
  def display_glossary(area):
93
  st.subheader(f"📘 Glossary for {area}")
94
  terms = transhuman_glossary[area]
95
  for idx, term in enumerate(terms, start=1):
96
- st.write(f"{idx}. {term}")
 
 
97
 
98
 
99
  # Function to display glossary in a 3x3 grid
@@ -104,18 +96,18 @@ def display_glossary_grid(glossary):
104
  ["🏛 Institutions", "🔗 Organizations", "⚔️ War"],
105
  ["🎖 Military", "🦹 Outlaws", "👽 Terrorists"],
106
  ]
107
-
108
  for group in groupings:
109
  cols = st.columns(3) # Create three columns
110
  for idx, category in enumerate(group):
111
  with cols[idx]:
112
- #st.markdown(f"### {category}")
113
-
114
  terms = glossary[category]
115
  for term in terms:
116
  t=term
117
-
118
- #st.write(f"- {t}")
119
 
120
  # Streamlined UI for displaying buttons with scores, integrating emojis
121
  def display_buttons_with_scores():
@@ -127,10 +119,11 @@ def display_buttons_with_scores():
127
  if st.button(f"{term} {score}🚀", key=key):
128
  update_score(key)
129
 
130
-
131
- # Bonus stage!
132
  search_glossary('Create a three level markdown outline with 3 subpoints each where each line defines and writes out the core technology descriptions with appropriate emojis for the glossary term: ' + term)
133
- st.experimental_rerun()
 
 
134
 
135
  def fetch_wikipedia_summary(keyword):
136
  # Placeholder function for fetching Wikipedia summaries
@@ -216,10 +209,6 @@ def display_content_or_image(query):
216
  return False
217
 
218
 
219
-
220
-
221
-
222
-
223
 
224
  # Imports
225
  import base64
 
3
  import json
4
  from PIL import Image
5
 
6
+ # 1. Boot
7
  st.set_page_config(
8
  page_title="🌌🚀ReMixable-AI-AR",
9
  page_icon="🌠",
 
15
  'About': "# Midjourney: https://discord.com/channels/@me/997514686608191558"
16
  }
17
  )
 
 
18
  transhuman_glossary = {
19
  "🚀 Core Technologies": ["Nanotechnology🔬", "Artificial Intelligence🤖", "Quantum Computing💻", "Spacecraft Engineering🛸", "Biotechnology🧬", "Cybernetics🦾", "Virtual Reality🕶️", "Energy Systems⚡", "Material Science🧪", "Communication Technologies📡"],
20
  "🌐 Nations": ["Terran Federation🌍", "Martian Syndicate🔴", "Jovian Republics🪐", "Asteroid Belt Communities🌌", "Venusian Colonies🌋", "Lunar States🌖", "Outer System Alliances✨", "Digital Consciousness Collectives🧠", "Transhumanist Enclaves🦿", "Non-Human Intelligence Tribes👽"],
 
27
  "👽 Terrorists": ["Bioengineered Virus Spreaders🧬💉", "Nanotechnology Saboteurs🔬🧨", "Cyber Terrorist Networks💻🔥", "Rogue AI Sects🤖🛑", "Space Anarchist Cells🚀Ⓐ", "Quantum Data Hijackers💻🔓", "Environmental Extremists🌍💣", "Technological Singularity Cults🤖🙏", "Interspecies Supremacists👽👑", "Orbital Bombardment Threats🛰️💥"],
28
  }
29
 
30
+
31
+ # 2. Scores
32
  score_dir = "scores"
33
  os.makedirs(score_dir, exist_ok=True)
 
 
34
  def generate_key(label, header, idx):
35
  return f"{header}_{label}_{idx}_key"
 
 
36
  def update_score(key, increment=1):
37
  score_file = os.path.join(score_dir, f"{key}.json")
38
  if os.path.exists(score_file):
 
40
  score_data = json.load(file)
41
  else:
42
  score_data = {"clicks": 0, "score": 0}
 
43
  score_data["clicks"] += 1
44
  score_data["score"] += increment
 
45
  with open(score_file, "w") as file:
46
  json.dump(score_data, file)
 
47
  return score_data["score"]
 
 
48
  def load_score(key):
49
  score_file = os.path.join(score_dir, f"{key}.json")
50
  if os.path.exists(score_file):
 
55
 
56
 
57
 
58
+ # 3. Search
59
  def search_glossary(query):
60
  for category, terms in transhuman_glossary.items():
61
  if query.lower() in (term.lower() for term in terms):
 
78
  # ------------------------------------------------------------------------------------------------
79
 
80
 
81
+ # 4. Glossary Cover with All Terms
82
  def display_glossary(area):
83
  st.subheader(f"📘 Glossary for {area}")
84
  terms = transhuman_glossary[area]
85
  for idx, term in enumerate(terms, start=1):
86
+ ShowAll=False
87
+ if ShowAll:
88
+ st.write(f"{idx}. {term}")
89
 
90
 
91
  # Function to display glossary in a 3x3 grid
 
96
  ["🏛 Institutions", "🔗 Organizations", "⚔️ War"],
97
  ["🎖 Military", "🦹 Outlaws", "👽 Terrorists"],
98
  ]
99
+ ShowAll=False
100
  for group in groupings:
101
  cols = st.columns(3) # Create three columns
102
  for idx, category in enumerate(group):
103
  with cols[idx]:
104
+ if ShowAll:
105
+ st.markdown(f"### {category}")
106
  terms = glossary[category]
107
  for term in terms:
108
  t=term
109
+ if ShowAll:
110
+ st.write(f"- {t}")
111
 
112
  # Streamlined UI for displaying buttons with scores, integrating emojis
113
  def display_buttons_with_scores():
 
119
  if st.button(f"{term} {score}🚀", key=key):
120
  update_score(key)
121
 
122
+ # Bonus stage! ------------------------------------------------------------------------------------------------------->
 
123
  search_glossary('Create a three level markdown outline with 3 subpoints each where each line defines and writes out the core technology descriptions with appropriate emojis for the glossary term: ' + term)
124
+ ReRun=False
125
+ If ReRun:
126
+ st.experimental_rerun()
127
 
128
  def fetch_wikipedia_summary(keyword):
129
  # Placeholder function for fetching Wikipedia summaries
 
209
  return False
210
 
211
 
 
 
 
 
212
 
213
  # Imports
214
  import base64