awacke1 commited on
Commit
5b3dda4
1 Parent(s): dac1d86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -163
app.py CHANGED
@@ -3,176 +3,53 @@ import os
3
  import json
4
  from PIL import Image
5
 
6
- st.set_page_config(page_title="🧠📖✍️Remixable AI🎨📓👨‍🏫", page_icon="🐉", layout="wide")
7
-
8
- glossary = {
9
- "💉 Vaccinate": ["mRNA vaccines", "Nanoparticle delivery systems", "Universal flu vaccine"],
10
- "🩺 Diagnose": ["AI-driven diagnostic tools", "Wearable health monitors", "Liquid biopsies"],
11
- "🏥 Hospital": ["Telemedicine", "Robot-assisted surgery", "Smart hospitals"],
12
- "🚑 Emergency": ["Point-of-care testing", "Drone delivery for medical supplies", "Mobile stroke units"],
13
- "💊 Meds": ["Precision medicine", "Biologics for chronic diseases", "Pharmacogenomics"],
14
- "🩹 Bandage": ["Smart bandages", "Biodegradable bandages", "Hydrogel bandages"],
15
- "🧬 DNA": ["Gene editing (CRISPR-Cas9)", "Gene therapy for inherited diseases", "Synthetic biology"],
16
- "🔬 Research": ["Big Data in healthcare", "3D bioprinting of tissues", "Nanotechnology in medicine"],
17
- "🌡️ Temperature": ["Wearable temperature monitors", "Infrared thermography", "Microfluidic devices"],
18
- "🍏 Nutrition": ["Personalized nutrition", "Nutrigenomics", "Functional foods"],
 
19
  }
20
 
21
- # Directory to store scores
22
- score_dir = "scores"
23
- os.makedirs(score_dir, exist_ok=True)
24
-
25
- # Function to generate a unique key for each button
26
- def generate_key(label, header, idx):
27
- return f"{header}_{label}_{idx}"
28
-
29
- # Function to increment score and save it
30
- def update_score(key, increment=1):
31
- score_file = os.path.join(score_dir, f"{key}.json")
32
- if os.path.exists(score_file):
33
- with open(score_file, "r") as file:
34
- score_data = json.load(file)
35
- else:
36
- score_data = {"clicks": 0, "score": 0}
37
-
38
- score_data["clicks"] += 1
39
- score_data["score"] += increment
40
-
41
- with open(score_file, "w") as file:
42
- json.dump(score_data, file)
43
-
44
- return score_data["score"]
45
-
46
- # Function to load score
47
- def load_score(key):
48
- score_file = os.path.join(score_dir, f"{key}.json")
49
- if os.path.exists(score_file):
50
- with open(score_file, "r") as file:
51
- score_data = json.load(file)
52
- return score_data["score"]
53
- return 0
54
-
55
- # Function to display the glossary for a selected area
56
  def display_glossary(area):
57
- st.subheader(f"Glossary for {area}")
58
- terms = glossary[area]
59
- for term in terms:
60
- st.write(f"- {term}")
61
 
62
- # Display headers and buttons with scores
63
  def display_buttons_with_scores():
64
- headers = ["Inputs", "Outputs", "Health", "Learning", "AI", "Writing"]
65
- buttons = [
66
- ["📝 Text", "📖 Read", "📷 Photo", "🖼️ View", "🎙️ Record", "🎧 Listen", "🎥 Video", "📹 Capture"],
67
- ["💬 Chat", "✍️ Write", "🎨 Art", "🌄 Create", "🎵 Music", "🎶 Compose", "📼 Watch", "🍿 Movies"],
68
- ["💉 Vaccinate", "🩺 Diagnose", "🏥 Hospital", "🚑 Emergency", "💊 Meds", "🩹 Bandage", "🧬 DNA", "🔬 Research", "🌡️ Temperature", "🍏 Nutrition"],
69
- ["📚 Study", "🧠 Brain", "👩‍🎓 Graduate", "📐 Measure", "🔍 Search", "📊 Analyze", "📋 Plan", "🖋️ Write", "👨‍🏫 Teach", "🧩 Puzzle"],
70
- ["🤖 Robot", "👾 Game", "💻 Code", "🧮 Calculate", "📡 Connect", "🔋 Power", "🕹️ Play", "🖥️ Display", "🧑‍💻 Develop", "👨‍🔬 Experiment"],
71
- ["✍️ Author", "📝 Note", "🖊️ Pen", "🖋️ Sign", "📚 Library", "🔖 Bookmark", "📓 Journal", "✒️ Ink", "📜 Scroll"]
72
- ]
 
 
 
 
 
73
 
74
- cols = st.columns(len(headers))
75
- for idx, (col, header, buttons_list) in enumerate(zip(cols, headers, buttons)):
76
- with col:
77
- st.markdown(f"### {header}")
78
- for button_idx, button_label in enumerate(buttons_list, start=1):
79
- key = generate_key(button_label, header, button_idx)
80
- score = load_score(key)
81
- if st.button(f"{button_label} {score}", key=key):
82
- new_score = update_score(key)
83
- # Reload the page to reflect the updated score
84
- st.experimental_rerun()
85
-
86
- # Display buttons for each area
87
- cols = st.columns(5)
88
- for i, (area, terms) in enumerate(glossary.items()):
89
- if cols[i % 5].button(area):
90
- display_glossary(area)
91
-
92
  # Main application logic
93
  if __name__ == "__main__":
94
- st.markdown('# Remixable!')
 
95
  display_buttons_with_scores()
96
 
97
- def fetch_wikipedia_summary(keyword):
98
- # Placeholder function for fetching Wikipedia summaries
99
- # In a real app, you might use requests to fetch from the Wikipedia API
100
- return f"Summary for {keyword}. For more information, visit Wikipedia."
101
-
102
- def create_search_url_youtube(keyword):
103
- base_url = "https://www.youtube.com/results?search_query="
104
- return base_url + keyword.replace(' ', '+')
105
-
106
- def create_search_url_bing(keyword):
107
- base_url = "https://www.bing.com/search?q="
108
- return base_url + keyword.replace(' ', '+')
109
-
110
- def create_search_url_wikipedia(keyword):
111
- base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
112
- return base_url + keyword.replace(' ', '+')
113
-
114
- def create_search_url_google(keyword):
115
- base_url = "https://www.google.com/search?q="
116
- return base_url + keyword.replace(' ', '+')
117
-
118
- def display_images_and_wikipedia_summaries():
119
- st.title('Gallery with Related Stories')
120
- image_files = [f for f in os.listdir('.') if f.endswith('.png')]
121
- if not image_files:
122
- st.write("No PNG images found in the current directory.")
123
- return
124
-
125
- for image_file in image_files:
126
- image = Image.open(image_file)
127
- st.image(image, caption=image_file, use_column_width=True)
128
-
129
- keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
130
-
131
- # Display Wikipedia and Google search links
132
- wikipedia_url = create_search_url_wikipedia(keyword)
133
- google_url = create_search_url_google(keyword)
134
- youtube_url = create_search_url_youtube(keyword)
135
- bing_url = create_search_url_bing(keyword)
136
-
137
- links_md = f"""
138
- [Wikipedia]({wikipedia_url}) |
139
- [Google]({google_url}) |
140
- [YouTube]({youtube_url}) |
141
- [Bing]({bing_url})
142
- """
143
- st.markdown(links_md)
144
-
145
- display_images_and_wikipedia_summaries()
146
-
147
- st.markdown('# 🩺 Remixable AI/UI/UX for Healers by Aaron Wacker')
148
-
149
- def get_all_query_params(key):
150
- return st.query_params().get(key, [])
151
-
152
- def clear_query_params():
153
- st.query_params()
154
-
155
- st.markdown("### Query Parameters - These Deep Link Map to Remixable Methods")
156
- st.write("Current Query Parameters:", st.query_params)
157
-
158
- # Example: Using query parameters to navigate or trigger functionalities
159
- if 'action' in st.query_params:
160
- action = st.query_params()['action'][0] # Get the first (or only) 'action' parameter
161
- if action == 'show_message':
162
- st.success("Showing a message because 'action=show_message' was found in the URL.")
163
- elif action == 'clear':
164
- clear_query_params()
165
- st.experimental_rerun()
166
-
167
- # Handling repeated keys
168
- if 'multi' in st.query_params:
169
- multi_values = get_all_query_params('multi')
170
- st.write("Values for 'multi':", multi_values)
171
-
172
- # Manual entry for demonstration
173
- st.write("Enter query parameters in the URL like this: ?action=show_message&multi=1&multi=2")
174
-
175
- # Clear query parameters button
176
- if st.button("Clear Query Parameters"):
177
- clear_query_params()
178
- st.experimental_rerun()
 
3
  import json
4
  from PIL import Image
5
 
6
+ # Set page configuration
7
+ st.set_page_config(page_title="🌌🚀 Remixable AI for Sci-Fi and Fantasy Storytelling", page_icon="🪐", layout="wide")
8
+
9
+ # Transhuman Space glossary
10
+ transhuman_glossary = {
11
+ "🚀 Core Technologies": ["Nanotechnology", "Artificial Intelligence", "Quantum Computing", "Spacecraft Engineering", "Biotechnology", "Cybernetics", "Virtual Reality", "Energy Systems", "Material Science", "Communication Technologies"],
12
+ "🌐 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"],
13
+ "💡 Memes": ["Post-Humanism", "Neo-Evolutionism", "Digital Ascendancy", "Solar System Nationalism", "Space Explorationism", "Cyber Democracy", "Interstellar Environmentalism", "Quantum Mysticism", "Techno-Anarchism", "Cosmic Preservationism"],
14
+ "🏛 Institutions": ["Interstellar Council", "Transhuman Ethical Standards Organization", "Galactic Trade Union", "Space Habitat Authority", "Artificial Intelligence Safety Commission", "Extraterrestrial Relations Board", "Quantum Research Institute", "Biogenetics Oversight Committee", "Cyberspace Regulatory Agency", "Planetary Defense Coalition"],
15
+ "🔗 Organizations": ["Neural Network Pioneers", "Spacecraft Innovators Guild", "Quantum Computing Consortium", "Interplanetary Miners Union", "Cybernetic Augmentation Advocates", "Biotechnological Harmony Group", "Stellar Navigation Circle", "Virtual Reality Creators Syndicate", "Renewable Energy Pioneers", "Transhuman Rights Activists"],
16
+ "⚔️ War": ["Space Warfare Tactics", "Cyber Warfare", "Biological Warfare", "Nanotech Warfare", "Psychological Operations", "Quantum Encryption & Decryption", "Kinetic Bombardment", "Energy Shield Defense", "Stealth Spacecraft", "Artificial Intelligence Combat"],
17
+ "🎖 Military": ["Interstellar Navy", "Planetary Guard", "Cybernetic Marines", "Nanotech Soldiers", "Space Drone Fleet", "Quantum Signal Corps", "Special Operations Forces", "Artificial Intelligence Strategists", "Orbital Defense Systems", "Exoskeleton Brigades"],
18
+ "🦹 Outlaws": ["Pirate Fleets", "Hacktivist Collectives", "Smuggler Caravans", "Rebel AI Entities", "Black Market Biotech Dealers", "Quantum Thieves", "Space Nomad Raiders", "Cyberspace Intruders", "Anti-Transhumanist Factions", "Rogue Nanotech Swarms"],
19
+ "👽 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"],
20
  }
21
 
22
+ # Function to display the glossary for a selected area with Streamlit components
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  def display_glossary(area):
24
+ st.subheader(f"📘 Glossary for {area}")
25
+ terms = transhuman_glossary[area]
26
+ for idx, term in enumerate(terms, start=1):
27
+ st.write(f"{idx}. {term}")
28
 
29
+ # Display headers and buttons with scores, adapted for Transhuman Space
30
  def display_buttons_with_scores():
31
+ headers = list(transhuman_glossary.keys())
32
+ for header in headers:
33
+ st.markdown(f"### {header}")
34
+ terms = transhuman_glossary[header]
35
+ for term in terms:
36
+ key = generate_key(term, header, terms.index(term))
37
+ score = load_score(key)
38
+ if st.button(f"{term} {score}", key=key):
39
+ new_score = update_score(key)
40
+ st.experimental_rerun()
41
+
42
+ # Adapt existing functions for Transhuman Space storytelling
43
+ # Additional functions like `fetch_wikipedia_summary` can be adapted for fetching information
44
+ # from a science fiction database or API if available.
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  # Main application logic
47
  if __name__ == "__main__":
48
+ st.title("🌌 Transhuman Space: An Encyclopedia for Role-Playing")
49
+ st.markdown("## Explore the intricacies of Transhuman Space through interactive storytelling and encyclopedic knowledge.")
50
  display_buttons_with_scores()
51
 
52
+ # Example extensions:
53
+ # - Implementing image galleries for spacecraft designs and characters.
54
+ # - Adding interactive maps of the solar system highlighting key locations in Transhuman Space.
55
+ # - Creating dynamic character and technology profiles that users can explore and modify.