awacke1 commited on
Commit
985b588
1 Parent(s): ef61983

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -38
app.py CHANGED
@@ -16,6 +16,41 @@ import os
16
  from datetime import datetime
17
  from gradio_client import Client
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def save_file(content, file_type):
20
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
21
  file_name = f"{file_type}_{timestamp}.md"
@@ -74,38 +109,6 @@ def main():
74
 
75
 
76
 
77
-
78
- import streamlit as st
79
- import streamlit.components.v1 as components
80
- import os
81
- import json
82
- import random
83
- import base64
84
- import glob
85
- import math
86
- import openai
87
- import pytz
88
- import re
89
- import requests
90
- import textract
91
- import time
92
- import zipfile
93
- import huggingface_hub
94
- import dotenv
95
- from audio_recorder_streamlit import audio_recorder
96
- from bs4 import BeautifulSoup
97
- from collections import deque
98
- from datetime import datetime
99
- from dotenv import load_dotenv
100
- from huggingface_hub import InferenceClient
101
- from io import BytesIO
102
- from openai import ChatCompletion
103
- from PyPDF2 import PdfReader
104
- from templates import bot_template, css, user_template
105
- from xml.etree import ElementTree as ET
106
- from PIL import Image
107
- from urllib.parse import quote # Ensure this import is included
108
-
109
  # Set page configuration with a title and favicon
110
  st.set_page_config(
111
  page_title="📖🔍WordGameAI",
@@ -1209,7 +1212,7 @@ def StreamMedChatResponse(topic):
1209
  # 17. Main
1210
  def arxivmain():
1211
  prompt = PromptPrefix2
1212
- with st.expander("Prompts 📚", expanded=False):
1213
  example_input = st.text_input("Enter your prompt text:", value=prompt, help="Enter text to get a response.")
1214
  if st.button("Run Prompt", help="Click to run."):
1215
  try:
@@ -1276,7 +1279,7 @@ def get_audio_download_link(file_path):
1276
  base64_file = get_base64_encoded_file(file_path)
1277
  return f'<a href="data:file/wav;base64,{base64_file}" download="{os.path.basename(file_path)}">⬇️ Download Audio</a>'
1278
 
1279
- # Compose a file sidebar of past encounters
1280
  all_files = glob.glob("*.wav")
1281
  all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
1282
  all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
@@ -1341,12 +1344,13 @@ except:
1341
  st.markdown(' ')
1342
 
1343
  # Display the glossary grid
1344
- st.markdown("### 🎲🗺️ Word Game Gallery")
1345
 
1346
- display_glossary_grid(roleplaying_glossary) # Word Glossary Jump Grid
1347
- display_buttons_with_scores() # Feedback Jump Grid
1348
  display_videos_and_links() # Video Jump Grid
1349
  display_images_and_wikipedia_summaries() # Image Jump Grid
 
 
1350
 
1351
 
1352
  if 'action' in st.query_params:
@@ -1379,7 +1383,6 @@ if st.button("Clear Query Parameters", key='ClearQueryParams'):
1379
  # 18. Run AI Pipeline
1380
  if __name__ == "__main__":
1381
  whisper_main()
1382
- arxivmain()
1383
  main()
1384
 
1385
 
 
16
  from datetime import datetime
17
  from gradio_client import Client
18
 
19
+
20
+
21
+ import streamlit as st
22
+ import streamlit.components.v1 as components
23
+ import os
24
+ import json
25
+ import random
26
+ import base64
27
+ import glob
28
+ import math
29
+ import openai
30
+ import pytz
31
+ import re
32
+ import requests
33
+ import textract
34
+ import time
35
+ import zipfile
36
+ import huggingface_hub
37
+ import dotenv
38
+ from audio_recorder_streamlit import audio_recorder
39
+ from bs4 import BeautifulSoup
40
+ from collections import deque
41
+ from datetime import datetime
42
+ from dotenv import load_dotenv
43
+ from huggingface_hub import InferenceClient
44
+ from io import BytesIO
45
+ from openai import ChatCompletion
46
+ from PyPDF2 import PdfReader
47
+ from templates import bot_template, css, user_template
48
+ from xml.etree import ElementTree as ET
49
+ from PIL import Image
50
+ from urllib.parse import quote # Ensure this import is included
51
+
52
+
53
+
54
  def save_file(content, file_type):
55
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
56
  file_name = f"{file_type}_{timestamp}.md"
 
109
 
110
 
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  # Set page configuration with a title and favicon
113
  st.set_page_config(
114
  page_title="📖🔍WordGameAI",
 
1212
  # 17. Main
1213
  def arxivmain():
1214
  prompt = PromptPrefix2
1215
+ with st.expander("Prompts 📚", expanded=True):
1216
  example_input = st.text_input("Enter your prompt text:", value=prompt, help="Enter text to get a response.")
1217
  if st.button("Run Prompt", help="Click to run."):
1218
  try:
 
1279
  base64_file = get_base64_encoded_file(file_path)
1280
  return f'<a href="data:file/wav;base64,{base64_file}" download="{os.path.basename(file_path)}">⬇️ Download Audio</a>'
1281
 
1282
+ # Sidebar of past encounters
1283
  all_files = glob.glob("*.wav")
1284
  all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
1285
  all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
 
1344
  st.markdown(' ')
1345
 
1346
  # Display the glossary grid
1347
+ st.markdown("### 🎲🗺️ Arxiv Paper Search QA RAG MAS using Streamlit and Gradio API")
1348
 
1349
+ arxivmain()
 
1350
  display_videos_and_links() # Video Jump Grid
1351
  display_images_and_wikipedia_summaries() # Image Jump Grid
1352
+ display_glossary_grid(roleplaying_glossary) # Word Glossary Jump Grid
1353
+ #display_buttons_with_scores() # Feedback Jump Grid
1354
 
1355
 
1356
  if 'action' in st.query_params:
 
1383
  # 18. Run AI Pipeline
1384
  if __name__ == "__main__":
1385
  whisper_main()
 
1386
  main()
1387
 
1388