awacke1 commited on
Commit
a534622
1 Parent(s): 52e62db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -154
app.py CHANGED
@@ -30,68 +30,13 @@ from xml.etree import ElementTree as ET
30
  from PIL import Image
31
  from urllib.parse import quote # Ensure this import is included
32
 
33
- def image(src_as_string, **style):
34
- return img(src=src_as_string, style=styles(**style))
35
-
36
- def link(link, text, **style):
37
- return a(_href=link, _target="_blank", style=styles(**style))(text)
38
-
39
- def layout(*args):
40
-
41
- style = """
42
- <style>
43
- # MainMenu {visibility: hidden;}
44
- footer {visibility: hidden;}
45
- </style>
46
- """
47
-
48
- style_div = styles(
49
- left=0,
50
- bottom=0,
51
- margin=px(0, 0, 0, 0),
52
- width=percent(100),
53
- text_align="center",
54
- height="60px",
55
- opacity=0.6
56
- )
57
-
58
- style_hr = styles(
59
- )
60
-
61
- body = p()
62
- foot = div(style=style_div)(hr(style=style_hr), body)
63
-
64
- st.markdown(style, unsafe_allow_html=True)
65
-
66
- for arg in args:
67
- if isinstance(arg, str):
68
- body(arg)
69
- elif isinstance(arg, HtmlElement):
70
- body(arg)
71
-
72
- st.markdown(str(foot), unsafe_allow_html=True)
73
-
74
- def footer():
75
- myargs = [
76
- "<b>Made with</b>: Python 3.8 ",
77
- link("https://www.python.org/", image('https://i.imgur.com/ml09ccU.png',
78
- width=18, height=18, margin= "0em")),
79
- ", Streamlit ",
80
- link("https://streamlit.io/", image('https://docs.streamlit.io/en/stable/_static/favicon.png',
81
- width=24, height=25, margin= "0em")),
82
- br(),
83
- ]
84
- layout(*myargs)
85
-
86
-
87
  # 1. Configuration
88
-
89
  Site_Name = 'Scholarly-Article-Document-Search-With-Memory'
90
  title="🚀🌌ArXiv Article Document Search Memory"
91
-
92
  helpURL='https://huggingface.co/awacke1'
93
  bugURL='https://huggingface.co/spaces/awacke1'
94
  icons='🔍🚀🌌📖'
 
95
  st.set_page_config(
96
  page_title=title,
97
  page_icon=icons,
@@ -105,13 +50,6 @@ st.set_page_config(
105
  )
106
 
107
 
108
- def save_file(content, file_type):
109
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
110
- file_name = f"{file_type}_{timestamp}.md"
111
- with open(file_name, "w") as file:
112
- file.write(content)
113
- return file_name
114
-
115
  def load_file(file_name):
116
  with open(file_name, "r", encoding='utf-8') as file:
117
  #with open(file_name, "r") as file:
@@ -216,52 +154,6 @@ PromptPrefix = 'Create a specification with streamlit functions creating markdow
216
  PromptPrefix2 = 'Create a streamlit python user app with full code listing to create a UI implementing the using streamlit, gradio, huggingface to create user interface elements like emoji buttons, sliders, drop downs, and data interfaces like dataframes to show tables, session_statematching this ruleset and thematic story plot line: '
217
  PromptPrefix3 = 'Create a HTML5 aframe and javascript app using appropriate libraries to create a word game simulation 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:'
218
 
219
- # Function to display the entire glossary in a grid format with links
220
-
221
- def display_glossary_grid(roleplaying_glossary):
222
- search_urls = {
223
- "📖Wiki": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
224
- "🔍Google": lambda k: f"https://www.google.com/search?q={quote(k)}",
225
- "🔎Bing": lambda k: f"https://www.bing.com/search?q={quote(k)}",
226
- "🎥YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
227
- "🐦Twitter": lambda k: f"https://twitter.com/search?q={quote(k)}",
228
- "🚀🌌ArXiv": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}", # this url plus query!
229
- "🃏Analyst": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix)}", # this url plus query!
230
- "📚PyCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix2)}", # this url plus query!
231
- "🔬JSCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix3)}", # this url plus query!
232
- }
233
-
234
- for category, details in roleplaying_glossary.items():
235
- st.write(f"### {category}")
236
- cols = st.columns(len(details)) # Create dynamic columns based on the number of games
237
- for idx, (game, terms) in enumerate(details.items()):
238
- with cols[idx]:
239
- st.markdown(f"#### {game}")
240
- for term in terms:
241
- gameterm = category + ' - ' + game + ' - ' + term
242
- links_md = ' '.join([f"[{emoji}]({url(gameterm)})" for emoji, url in search_urls.items()])
243
- #links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
244
- #st.markdown(f"{term} {links_md}", unsafe_allow_html=True)
245
- st.markdown(f"**{term}** <small>{links_md}</small>", unsafe_allow_html=True)
246
-
247
-
248
- def display_glossary_entity(k):
249
- search_urls = {
250
- "📖Wiki": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
251
- "🔍Google": lambda k: f"https://www.google.com/search?q={quote(k)}",
252
- "🔎Bing": lambda k: f"https://www.bing.com/search?q={quote(k)}",
253
- "🎥YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
254
- "🐦Twitter": lambda k: f"https://twitter.com/search?q={quote(k)}",
255
- "🚀🌌ArXiv": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}", # this url plus query!
256
- "🃏Analyst": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix)}", # this url plus query!
257
- "📚PyCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix2)}", # this url plus query!
258
- "🔬JSCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix3)}", # this url plus query!
259
- }
260
- links_md = ' '.join([f"[{emoji}]({url(k)})" for emoji, url in search_urls.items()])
261
- #st.markdown(f"{k} {links_md}", unsafe_allow_html=True)
262
- st.markdown(f"**{k}** <small>{links_md}</small>", unsafe_allow_html=True)
263
-
264
-
265
 
266
  roleplaying_glossary = {
267
  "🤖 AI Concepts": {
@@ -388,6 +280,52 @@ roleplaying_glossary = {
388
  }
389
 
390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  @st.cache_resource
392
  def get_table_download_link(file_path):
393
 
@@ -456,34 +394,24 @@ def SaveFileNameClicked():
456
 
457
  def FileSidebar():
458
  # ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
459
- # Compose a file sidebar of markdown md files:
460
  all_files = glob.glob("*.md")
461
  all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
462
  all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
463
-
464
- # Delete and Download:
465
  Files1, Files2 = st.sidebar.columns(2)
466
-
467
  with Files1:
468
  if st.button("🗑 Delete All"):
469
  for file in all_files:
470
  os.remove(file)
471
  st.experimental_rerun()
472
-
473
  with Files2:
474
  if st.button("⬇️ Download"):
475
  zip_file = create_zip_of_files(all_files)
476
  st.sidebar.markdown(get_zip_download_link(zip_file), unsafe_allow_html=True)
477
-
478
-
479
-
480
-
481
-
482
  file_contents=''
483
  file_name=''
484
  next_action=''
485
 
486
- # FileSidebar Adds files matching pattern to sidebar where we feature a 🌐View, 📂Open, ▶️Run, and 🗑Delete per file
487
  for file in all_files:
488
  col1, col2, col3, col4, col5 = st.sidebar.columns([1,6,1,1,1]) # adjust the ratio as needed
489
  with col1:
@@ -576,8 +504,18 @@ def FileSidebar():
576
  #st.markdown('GPT is sleeping. Restart ETA 30 seconds.')
577
  # ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
578
 
579
- # Bass Drum Title -
580
- st.markdown("""**🎺🎷 The Sounds 🎹🥁 of the Big Easy 🎭🎉 🎼🎸 NOLA's Iconic 🎤🪕 Musical 🔊 Heritage 🏰 🎺🪘 Crescent City 🌙 Rhythms & Grooves 🎹💃 🎷🎸 Mardi Gras 🎭 Melodies: 🎼🎺 Straight Outta Nawlins ⚜️ 🥁🎻 Jazzy 🎷 Jambalaya 🍛 of New Orleans' 🏰 Musical 🎹 Soul 🙌The Music Of New Orleans MoE**""")
 
 
 
 
 
 
 
 
 
 
581
 
582
 
583
  FileSidebar()
@@ -733,35 +671,8 @@ def display_glossary(glossary, area):
733
  st.write(f"{idx}. {term}")
734
 
735
 
736
- # Function to display the entire glossary in a grid format with links
737
- @st.cache_resource
738
- def display_glossary_grid(roleplaying_glossary):
739
- search_urls = {
740
- "📖Wiki": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
741
- "🔍Google": lambda k: f"https://www.google.com/search?q={quote(k)}",
742
- "▶️YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
743
- "🔎Bing": lambda k: f"https://www.bing.com/search?q={quote(k)}",
744
- "🎥YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
745
- "🐦Twitter": lambda k: f"https://twitter.com/search?q={quote(k)}",
746
- "🚀🌌ArXiv": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}", # this url plus query!
747
- "🃏Analyst": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix)}", # this url plus query!
748
- "📚PyCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix2)}", # this url plus query!
749
- "🔬JSCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix3)}", # this url plus query!
750
- }
751
 
752
- for category, details in roleplaying_glossary.items():
753
- st.write(f"### {category}")
754
- cols = st.columns(len(details)) # Create dynamic columns based on the number of games
755
- #cols = st.columns(num_columns_text) # Create dynamic columns based on the number of games
756
- for idx, (game, terms) in enumerate(details.items()):
757
- with cols[idx]:
758
- st.markdown(f"#### {game}")
759
- for term in terms:
760
- links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
761
- st.markdown(f"**{term}** <small>{links_md}</small>", unsafe_allow_html=True)
762
-
763
-
764
- @st.cache_resource
765
  def display_videos_and_links(num_columns):
766
  video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
767
  if not video_files:
@@ -782,7 +693,7 @@ def display_videos_and_links(num_columns):
782
  display_glossary_entity(k)
783
  col_index += 1 # Increment column index to place the next video in the next column
784
 
785
- @st.cache_resource
786
  def display_images_and_wikipedia_summaries(num_columns=4):
787
  image_files = [f for f in os.listdir('.') if f.endswith('.png')]
788
  if not image_files:
@@ -1488,6 +1399,3 @@ display_glossary_grid(roleplaying_glossary) # Word Glossary Jump Grid - Dynamic
1488
  num_columns_text=st.slider(key="num_columns_text", label="Choose Number of Text Columns", min_value=1, max_value=10, value=4)
1489
  display_buttons_with_scores(num_columns_text) # Feedback Jump Grid
1490
 
1491
-
1492
-
1493
- #footer()
 
30
  from PIL import Image
31
  from urllib.parse import quote # Ensure this import is included
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  # 1. Configuration
 
34
  Site_Name = 'Scholarly-Article-Document-Search-With-Memory'
35
  title="🚀🌌ArXiv Article Document Search Memory"
 
36
  helpURL='https://huggingface.co/awacke1'
37
  bugURL='https://huggingface.co/spaces/awacke1'
38
  icons='🔍🚀🌌📖'
39
+
40
  st.set_page_config(
41
  page_title=title,
42
  page_icon=icons,
 
50
  )
51
 
52
 
 
 
 
 
 
 
 
53
  def load_file(file_name):
54
  with open(file_name, "r", encoding='utf-8') as file:
55
  #with open(file_name, "r") as file:
 
154
  PromptPrefix2 = 'Create a streamlit python user app with full code listing to create a UI implementing the using streamlit, gradio, huggingface to create user interface elements like emoji buttons, sliders, drop downs, and data interfaces like dataframes to show tables, session_statematching this ruleset and thematic story plot line: '
155
  PromptPrefix3 = 'Create a HTML5 aframe and javascript app using appropriate libraries to create a word game simulation 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:'
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  roleplaying_glossary = {
159
  "🤖 AI Concepts": {
 
280
  }
281
 
282
 
283
+ # This displays per video and per image.
284
+ #@st.cache_resource
285
+ def display_glossary_entity(k):
286
+ search_urls = {
287
+ "🚀🌌ArXiv": lambda k: f"/?q={quote(k)}", # this url plus query!
288
+ "🃏Analyst": lambda k: f"/?q={quote(k)}-{quote(PromptPrefix)}", # this url plus query!
289
+ "📚PyCoder": lambda k: f"/?q={quote(k)}-{quote(PromptPrefix2)}", # this url plus query!
290
+ "🔬JSCoder": lambda k: f"/?q={quote(k)}-{quote(PromptPrefix3)}", # this url plus query!
291
+ "📖Wiki": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
292
+ "🔍Google": lambda k: f"https://www.google.com/search?q={quote(k)}",
293
+ "🔎Bing": lambda k: f"https://www.bing.com/search?q={quote(k)}",
294
+ "🎥YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
295
+ "🐦Twitter": lambda k: f"https://twitter.com/search?q={quote(k)}",
296
+ }
297
+ links_md = ' '.join([f"[{emoji}]({url(k)})" for emoji, url in search_urls.items()])
298
+ #st.markdown(f"{k} {links_md}", unsafe_allow_html=True)
299
+ st.markdown(f"**{k}** <small>{links_md}</small>", unsafe_allow_html=True)
300
+
301
+ # Function to display the entire glossary in a grid format with links
302
+ @st.cache_resource
303
+ def display_glossary_grid(roleplaying_glossary):
304
+ search_urls = {
305
+ "🚀🌌ArXiv": lambda k: f"/?q={quote(k)}", # this url plus query!
306
+ "📖Wiki": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
307
+ "🔍Google": lambda k: f"https://www.google.com/search?q={quote(k)}",
308
+ "▶️YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
309
+ "🔎Bing": lambda k: f"https://www.bing.com/search?q={quote(k)}",
310
+ "🎥YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
311
+ "🐦Twitter": lambda k: f"https://twitter.com/search?q={quote(k)}",
312
+ "🃏Analyst": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix)}", # this url plus query!
313
+ "📚PyCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix2)}", # this url plus query!
314
+ "🔬JSCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix3)}", # this url plus query!
315
+ }
316
+
317
+ for category, details in roleplaying_glossary.items():
318
+ st.write(f"### {category}")
319
+ cols = st.columns(len(details)) # Create dynamic columns based on the number of games
320
+ #cols = st.columns(num_columns_text) # Create dynamic columns based on the number of games
321
+ for idx, (game, terms) in enumerate(details.items()):
322
+ with cols[idx]:
323
+ st.markdown(f"#### {game}")
324
+ for term in terms:
325
+ links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
326
+ st.markdown(f"**{term}** <small>{links_md}</small>", unsafe_allow_html=True)
327
+
328
+
329
  @st.cache_resource
330
  def get_table_download_link(file_path):
331
 
 
394
 
395
  def FileSidebar():
396
  # ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
 
397
  all_files = glob.glob("*.md")
398
  all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
399
  all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
 
 
400
  Files1, Files2 = st.sidebar.columns(2)
 
401
  with Files1:
402
  if st.button("🗑 Delete All"):
403
  for file in all_files:
404
  os.remove(file)
405
  st.experimental_rerun()
 
406
  with Files2:
407
  if st.button("⬇️ Download"):
408
  zip_file = create_zip_of_files(all_files)
409
  st.sidebar.markdown(get_zip_download_link(zip_file), unsafe_allow_html=True)
 
 
 
 
 
410
  file_contents=''
411
  file_name=''
412
  next_action=''
413
 
414
+ # Add files 🌐View, 📂Open, ▶️Run, and 🗑Delete per file
415
  for file in all_files:
416
  col1, col2, col3, col4, col5 = st.sidebar.columns([1,6,1,1,1]) # adjust the ratio as needed
417
  with col1:
 
504
  #st.markdown('GPT is sleeping. Restart ETA 30 seconds.')
505
  # ----------------------------------------------------- File Sidebar for Jump Gates ------------------------------------------
506
 
507
+ # Randomly select a title
508
+ titles = [
509
+ "🎺🎷 The Sounds 🎹🥁 of the Big Easy 🎭🎉",
510
+ "🎼🎸 NOLA's Iconic 🎤🪕 Musical 🔊 Heritage 🏰",
511
+ "🎺🪘 Crescent City 🌙 Rhythms & Grooves 🎹💃",
512
+ "🎷🎸 Mardi Gras 🎭 Melodies",
513
+ "🎼🎺 Straight Outta Nawlins ⚜️",
514
+ "🥁🎻 Jazzy 🎷 Jambalaya 🍛 of New Orleans' 🏰 Musical 🎹 Soul 🙌",
515
+ "🥁🎻 The Music Of New Orleans MoE 🎭🎉"
516
+ ]
517
+ selected_title = random.choice(titles)
518
+ st.markdown(f"**{selected_title}**")
519
 
520
 
521
  FileSidebar()
 
671
  st.write(f"{idx}. {term}")
672
 
673
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
 
675
+ #@st.cache_resource
 
 
 
 
 
 
 
 
 
 
 
 
676
  def display_videos_and_links(num_columns):
677
  video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
678
  if not video_files:
 
693
  display_glossary_entity(k)
694
  col_index += 1 # Increment column index to place the next video in the next column
695
 
696
+ #@st.cache_resource
697
  def display_images_and_wikipedia_summaries(num_columns=4):
698
  image_files = [f for f in os.listdir('.') if f.endswith('.png')]
699
  if not image_files:
 
1399
  num_columns_text=st.slider(key="num_columns_text", label="Choose Number of Text Columns", min_value=1, max_value=10, value=4)
1400
  display_buttons_with_scores(num_columns_text) # Feedback Jump Grid
1401