Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,8 +43,81 @@ st.set_page_config(
|
|
43 |
}
|
44 |
)
|
45 |
|
46 |
-
PromptPrefix = 'Create a markdown outline and table with appropriate emojis for body map which define the definition parts, function, conditions of the topic of '
|
47 |
-
PromptPrefix2 = 'Create a streamlit python user app. Show full code listing. Create a UI implementing each feature using variables, reusable functions with parameters, and data driven app with python libraries and streamlit components for Javascript and HTML5. Use appropriate emojis for labels to summarize and list parts, function, conditions for topic: '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
st.markdown('''### ๐ง ๐ช BodyMapAI''')
|
50 |
with st.expander("Help / About ๐", expanded=False):
|
@@ -256,28 +329,6 @@ def display_glossary(glossary, area):
|
|
256 |
st.write(f"{idx}. {term}")
|
257 |
|
258 |
|
259 |
-
# Function to display the entire glossary in a grid format with links
|
260 |
-
def display_glossary_grid(body_map_data):
|
261 |
-
search_urls = {
|
262 |
-
"๐": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
|
263 |
-
"๐": lambda k: f"https://www.google.com/search?q={quote(k)}",
|
264 |
-
"โถ๏ธ": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
265 |
-
"๐": lambda k: f"https://www.bing.com/search?q={quote(k)}",
|
266 |
-
"๐ฒ": lambda k: f"https://huggingface.co/spaces/awacke1/AI-ChatGPT-CPT-Body-Map-Cost?q={quote(k)}", # this url plus query!
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
for category, details in body_map_data.items():
|
271 |
-
st.write(f"### {category}")
|
272 |
-
cols = st.columns(len(details)) # Create dynamic columns based on the number of games
|
273 |
-
for idx, (game, terms) in enumerate(details.items()):
|
274 |
-
with cols[idx]:
|
275 |
-
st.markdown(f"#### {game}")
|
276 |
-
for term in terms:
|
277 |
-
links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
|
278 |
-
st.markdown(f"{term} {links_md}", unsafe_allow_html=True)
|
279 |
-
|
280 |
-
|
281 |
game_emojis = {
|
282 |
"Dungeons and Dragons": "๐",
|
283 |
"Call of Cthulhu": "๐",
|
@@ -321,61 +372,50 @@ def display_buttons_with_scores():
|
|
321 |
response = search_glossary(query_prefix + query_body)
|
322 |
|
323 |
|
324 |
-
def fetch_wikipedia_summary(keyword):
|
325 |
-
# Placeholder function for fetching Wikipedia summaries
|
326 |
-
# In a real app, you might use requests to fetch from the Wikipedia API
|
327 |
-
return f"Summary for {keyword}. For more information, visit Wikipedia."
|
328 |
-
|
329 |
-
def create_search_url_youtube(keyword):
|
330 |
-
base_url = "https://www.youtube.com/results?search_query="
|
331 |
-
return base_url + keyword.replace(' ', '+')
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
340 |
|
341 |
-
|
342 |
-
|
343 |
-
return base_url + keyword.replace(' ', '+')
|
344 |
|
345 |
-
|
346 |
-
|
347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
|
|
|
349 |
def display_images_and_wikipedia_summaries():
|
350 |
-
st.markdown('### Body Map Condition AI ๐๐๐')
|
351 |
-
|
352 |
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
353 |
if not image_files:
|
354 |
st.write("No PNG images found in the current directory.")
|
355 |
return
|
356 |
-
|
357 |
-
for
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
links_md = f"""
|
372 |
-
[Wikipedia]({wikipedia_url}) |
|
373 |
-
[Google]({google_url}) |
|
374 |
-
[YouTube]({youtube_url}) |
|
375 |
-
[Bing]({bing_url}) |
|
376 |
-
[AI]({ai_url})
|
377 |
-
"""
|
378 |
-
st.markdown(links_md)
|
379 |
|
380 |
|
381 |
def get_all_query_params(key):
|
@@ -1131,27 +1171,22 @@ def main():
|
|
1131 |
|
1132 |
try:
|
1133 |
query_params = st.query_params
|
1134 |
-
#query = (query_params.get('q') or query_params.get('query') or [''])[0]
|
1135 |
query = (query_params.get('q') or query_params.get('query') or [''])
|
1136 |
st.markdown('# Running query: ' + query)
|
1137 |
if query: search_glossary(query)
|
1138 |
except:
|
1139 |
-
st.markdown('
|
|
|
|
|
|
|
|
|
1140 |
|
1141 |
# Display the glossary grid
|
|
|
1142 |
display_images_and_wikipedia_summaries()
|
1143 |
-
st.title("Body Map Glossary ๐ฒ")
|
1144 |
display_glossary_grid(roleplaying_glossary)
|
1145 |
-
st.title("๐ฒ๐บ๏ธ Body Map Conditions")
|
1146 |
-
st.markdown("## Explore the body with a body scan map which fosters self knowledge about the body.๐ ")
|
1147 |
-
|
1148 |
display_buttons_with_scores()
|
1149 |
|
1150 |
-
|
1151 |
-
# Assuming the roleplaying_glossary and other setup code remains the same
|
1152 |
-
#st.write("Current Query Parameters:", st.query_params)
|
1153 |
-
#st.markdown("### Query Parameters - These Deep Link Map to Remixable Methods, Navigate or Trigger Functionalities")
|
1154 |
-
|
1155 |
# Example: Using query parameters to navigate or trigger functionalities
|
1156 |
if 'action' in st.query_params:
|
1157 |
action = st.query_params()['action'][0] # Get the first (or only) 'action' parameter
|
|
|
43 |
}
|
44 |
)
|
45 |
|
46 |
+
#PromptPrefix = 'Create a markdown outline and table with appropriate emojis for body map which define the definition parts, function, conditions of the topic of '
|
47 |
+
#PromptPrefix2 = 'Create a streamlit python user app. Show full code listing. Create a UI implementing each feature using variables, reusable functions with parameters, and data driven app with python libraries and streamlit components for Javascript and HTML5. Use appropriate emojis for labels to summarize and list parts, function, conditions for topic: '
|
48 |
+
|
49 |
+
# Prompts for App, for App Product, and App Product Code
|
50 |
+
PromptPrefix = 'Create a body and brain health, medical, biological and knowledge outline featuring insights for medical and pharmacy professionals with streamlit markdown outlines and tables with appropriate emojis for methodical step by step rules defining the game play rules. Use story structure architect rules to plan, structure and write three dramatic situations to include in the word game rules matching the theme for topic of '
|
51 |
+
PromptPrefix2 = 'Create a streamlit python app with full code listing to create a UI implementing the plans, structure, situations and tables as python functions creating a body and brain health, medical, biological and knowledge outline featuring insights for medical and pharmacy professionals using streamlit to create user interface elements like emoji buttons, sliders, drop downs, and data interfaces like dataframes to show tables, session_state to track inventory, character advancement and experience, locations, file_uploader to allow the user to add images which are saved and referenced shown in gallery, camera_input to take character picture, on_change = function callbacks with continual running plots that change when you change data or click a button, randomness and word and letter rolls using emojis and st.markdown, st.expander for groupings and clusters of things, st.columns and other UI controls in streamlit as a game. Create inline data tables and list dictionaries for entities implemented as variables for the word game rule entities and stats. Design it as a fun data driven game app and show full python code listing for this ruleset and thematic story plot line: '
|
52 |
+
PromptPrefix3 = 'Create a HTML5 aframe and javascript app using appropriate libraries to create a body and brain health, medical, biological and knowledge outline featuring insights for medical and pharmacy professionals with advanced libraries like aframe to render 3d scenes creating moving entities that stay within a bounding box but show text and animation in 3d for inventory, components and story entities. Show full code listing. Add a list of new random entities say 3 of a few different types to any list appropriately and use emojis to make things easier and fun to read. Use appropriate emojis in labels. Create the UI to implement storytelling in the style of a dungeon master, with features using three emoji appropriate text plot twists and recurring interesting funny fascinating and complex almost poetic named characters with genius traits and file IO, randomness, ten point choice lists, math distribution tradeoffs, witty humorous dilemnas with emoji , rewards, variables, reusable functions with parameters, and data driven app with python libraries and streamlit components for Javascript and HTML5. Use appropriate emojis for labels to summarize and list parts, function, conditions for topic:'
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
# Function to display the entire glossary in a grid format with links
|
57 |
+
def display_glossary_grid(roleplaying_glossary):
|
58 |
+
search_urls = {
|
59 |
+
"๐": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
|
60 |
+
"๐": lambda k: f"https://www.google.com/search?q={quote(k)}",
|
61 |
+
"โถ๏ธ": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
62 |
+
"๐": lambda k: f"https://www.bing.com/search?q={quote(k)}",
|
63 |
+
"๐ฆ": lambda k: f"https://twitter.com/search?q={quote(k)}",
|
64 |
+
"๐ฒ": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(k)}", # this url plus query!
|
65 |
+
"๐": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(PromptPrefix)}{quote(k)}", # this url plus query!
|
66 |
+
"๐": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(PromptPrefix2)}{quote(k)}", # this url plus query!
|
67 |
+
"๐": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(PromptPrefix3)}{quote(k)}", # this url plus query!
|
68 |
+
}
|
69 |
+
|
70 |
+
for category, details in roleplaying_glossary.items():
|
71 |
+
st.write(f"### {category}")
|
72 |
+
cols = st.columns(len(details)) # Create dynamic columns based on the number of games
|
73 |
+
for idx, (game, terms) in enumerate(details.items()):
|
74 |
+
with cols[idx]:
|
75 |
+
st.markdown(f"#### {game}")
|
76 |
+
for term in terms:
|
77 |
+
links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
|
78 |
+
st.markdown(f"{term} {links_md}", unsafe_allow_html=True)
|
79 |
+
|
80 |
+
def display_glossary_entity(k):
|
81 |
+
search_urls = {
|
82 |
+
"๐": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
|
83 |
+
"๐": lambda k: f"https://www.google.com/search?q={quote(k)}",
|
84 |
+
"โถ๏ธ": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
85 |
+
"๐": lambda k: f"https://www.bing.com/search?q={quote(k)}",
|
86 |
+
"๐ฆ": lambda k: f"https://twitter.com/search?q={quote(k)}",
|
87 |
+
"๐ฒ": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(k)}", # this url plus query!
|
88 |
+
"๐": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(PromptPrefix)}{quote(k)}", # this url plus query!
|
89 |
+
"๐": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(PromptPrefix2)}{quote(k)}", # this url plus query!
|
90 |
+
"๐": lambda k: f"https://huggingface.co/spaces/awacke1/WordGameAI?q={quote(PromptPrefix3)}{quote(k)}", # this url plus query!
|
91 |
+
}
|
92 |
+
links_md = ' '.join([f"[{emoji}]({url(k)})" for emoji, url in search_urls.items()])
|
93 |
+
st.markdown(f"{k} {links_md}", unsafe_allow_html=True)
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
|
98 |
+
# Function to display the entire glossary in a grid format with links
|
99 |
+
def display_glossary_grid_old(body_map_data):
|
100 |
+
search_urls = {
|
101 |
+
"๐": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
|
102 |
+
"๐": lambda k: f"https://www.google.com/search?q={quote(k)}",
|
103 |
+
"โถ๏ธ": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
104 |
+
"๐": lambda k: f"https://www.bing.com/search?q={quote(k)}",
|
105 |
+
"๐ฒ": lambda k: f"https://huggingface.co/spaces/awacke1/AI-ChatGPT-CPT-Body-Map-Cost?q={quote(k)}", # this url plus query!
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
for category, details in body_map_data.items():
|
110 |
+
st.write(f"### {category}")
|
111 |
+
cols = st.columns(len(details)) # Create dynamic columns based on the number of games
|
112 |
+
for idx, (game, terms) in enumerate(details.items()):
|
113 |
+
with cols[idx]:
|
114 |
+
st.markdown(f"#### {game}")
|
115 |
+
for term in terms:
|
116 |
+
links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
|
117 |
+
st.markdown(f"{term} {links_md}", unsafe_allow_html=True)
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
|
122 |
st.markdown('''### ๐ง ๐ช BodyMapAI''')
|
123 |
with st.expander("Help / About ๐", expanded=False):
|
|
|
329 |
st.write(f"{idx}. {term}")
|
330 |
|
331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
game_emojis = {
|
333 |
"Dungeons and Dragons": "๐",
|
334 |
"Call of Cthulhu": "๐",
|
|
|
372 |
response = search_glossary(query_prefix + query_body)
|
373 |
|
374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
|
376 |
+
@st.cache_resource
|
377 |
+
def display_videos_and_links():
|
378 |
+
video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
|
379 |
+
if not video_files:
|
380 |
+
st.write("No MP4 videos found in the current directory.")
|
381 |
+
return
|
382 |
+
|
383 |
+
video_files_sorted = sorted(video_files, key=lambda x: len(x.split('.')[0]))
|
384 |
|
385 |
+
cols = st.columns(2) # Define 2 columns outside the loop
|
386 |
+
col_index = 0 # Initialize column index
|
|
|
387 |
|
388 |
+
for video_file in video_files_sorted:
|
389 |
+
with cols[col_index % 2]: # Use modulo 2 to alternate between the first and second column
|
390 |
+
# Embedding video with autoplay and loop using HTML
|
391 |
+
#video_html = ("""<video width="100%" loop autoplay> <source src="{video_file}" type="video/mp4">Your browser does not support the video tag.</video>""")
|
392 |
+
#st.markdown(video_html, unsafe_allow_html=True)
|
393 |
+
k = video_file.split('.')[0] # Assumes keyword is the file name without extension
|
394 |
+
st.video(video_file, format='video/mp4', start_time=0)
|
395 |
+
display_glossary_entity(k)
|
396 |
+
col_index += 1 # Increment column index to place the next video in the next column
|
397 |
|
398 |
+
@st.cache_resource
|
399 |
def display_images_and_wikipedia_summaries():
|
|
|
|
|
400 |
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
401 |
if not image_files:
|
402 |
st.write("No PNG images found in the current directory.")
|
403 |
return
|
404 |
+
image_files_sorted = sorted(image_files, key=lambda x: len(x.split('.')[0]))
|
405 |
+
grid_sizes = [len(f.split('.')[0]) for f in image_files_sorted]
|
406 |
+
col_sizes = ['small' if size <= 4 else 'medium' if size <= 8 else 'large' for size in grid_sizes]
|
407 |
+
num_columns_map = {"small": 4, "medium": 3, "large": 2}
|
408 |
+
current_grid_size = 0
|
409 |
+
for image_file, col_size in zip(image_files_sorted, col_sizes):
|
410 |
+
if current_grid_size != num_columns_map[col_size]:
|
411 |
+
cols = st.columns(num_columns_map[col_size])
|
412 |
+
current_grid_size = num_columns_map[col_size]
|
413 |
+
col_index = 0
|
414 |
+
with cols[col_index % current_grid_size]:
|
415 |
+
image = Image.open(image_file)
|
416 |
+
st.image(image, caption=image_file, use_column_width=True)
|
417 |
+
k = image_file.split('.')[0] # Assumes keyword is the file name without extension
|
418 |
+
display_glossary_entity(k)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
|
420 |
|
421 |
def get_all_query_params(key):
|
|
|
1171 |
|
1172 |
try:
|
1173 |
query_params = st.query_params
|
|
|
1174 |
query = (query_params.get('q') or query_params.get('query') or [''])
|
1175 |
st.markdown('# Running query: ' + query)
|
1176 |
if query: search_glossary(query)
|
1177 |
except:
|
1178 |
+
st.markdown(' ')
|
1179 |
+
|
1180 |
+
st.title("๐ฒ๐บ๏ธ Body Map Conditions")
|
1181 |
+
#st.markdown("## Explore the body with a body scan map which fosters self knowledge about the body.๐ ")
|
1182 |
+
#st.title("Body Map Glossary ๐ฒ")
|
1183 |
|
1184 |
# Display the glossary grid
|
1185 |
+
display_videos_and_links() # Video Jump Grid
|
1186 |
display_images_and_wikipedia_summaries()
|
|
|
1187 |
display_glossary_grid(roleplaying_glossary)
|
|
|
|
|
|
|
1188 |
display_buttons_with_scores()
|
1189 |
|
|
|
|
|
|
|
|
|
|
|
1190 |
# Example: Using query parameters to navigate or trigger functionalities
|
1191 |
if 'action' in st.query_params:
|
1192 |
action = st.query_params()['action'][0] # Get the first (or only) 'action' parameter
|