Update app.py
Browse files
app.py
CHANGED
@@ -79,6 +79,10 @@ def load_file(file_name):
|
|
79 |
with open(file_name, "r") as file:
|
80 |
content = file.read()
|
81 |
return content
|
|
|
|
|
|
|
|
|
82 |
#import streamlit as st
|
83 |
#from gradio_client import Client
|
84 |
#client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
@@ -91,6 +95,42 @@ def load_file(file_name):
|
|
91 |
#)
|
92 |
#st.markdown(result)
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
def search_arxiv(query):
|
95 |
st.title("βΆοΈ Semantic and Episodic Memory System")
|
96 |
|
@@ -112,10 +152,18 @@ def search_arxiv(query):
|
|
112 |
)
|
113 |
|
114 |
# Show ArXiv Scholary Articles! ----------------*************-------------***************----------------------------------------
|
|
|
115 |
st.markdown(result)
|
116 |
-
|
|
|
|
|
|
|
|
|
117 |
SpeechSynthesis(result) # Search History Reader / Writer IO Memory - Audio at Same time as Reading.
|
118 |
|
|
|
|
|
|
|
119 |
filename=generate_filename(result, "md")
|
120 |
base_filename, ext = os.path.splitext(filename)
|
121 |
with open(f"{base_filename}.md", 'w') as file:
|
@@ -137,7 +185,6 @@ def search_arxiv(query):
|
|
137 |
|
138 |
|
139 |
create_file(filename, query, result, should_save)
|
140 |
-
# Show ArXiv Scholary Articles! ----------------*************-------------***************----------------------------------------
|
141 |
|
142 |
|
143 |
file_type = st.radio("Select Which Type of Memory You Prefer:", ("Semantic", "Episodic"))
|
@@ -362,36 +409,6 @@ roleplaying_glossary = {
|
|
362 |
|
363 |
|
364 |
|
365 |
-
# HTML5 based Speech Synthesis (Text to Speech in Browser)
|
366 |
-
@st.cache_resource
|
367 |
-
def SpeechSynthesis(result):
|
368 |
-
documentHTML5='''
|
369 |
-
<!DOCTYPE html>
|
370 |
-
<html>
|
371 |
-
<head>
|
372 |
-
<title>Read It Aloud</title>
|
373 |
-
<script type="text/javascript">
|
374 |
-
function readAloud() {
|
375 |
-
const text = document.getElementById("textArea").value;
|
376 |
-
const speech = new SpeechSynthesisUtterance(text);
|
377 |
-
window.speechSynthesis.speak(speech);
|
378 |
-
}
|
379 |
-
</script>
|
380 |
-
</head>
|
381 |
-
<body>
|
382 |
-
<h1>π Read It Aloud</h1>
|
383 |
-
<textarea id="textArea" rows="10" cols="80">
|
384 |
-
'''
|
385 |
-
documentHTML5 = documentHTML5 + result
|
386 |
-
documentHTML5 = documentHTML5 + '''
|
387 |
-
</textarea>
|
388 |
-
<br>
|
389 |
-
<button onclick="readAloud()">π Read Aloud</button>
|
390 |
-
</body>
|
391 |
-
</html>
|
392 |
-
'''
|
393 |
-
components.html(documentHTML5, width=1280, height=300)
|
394 |
-
|
395 |
|
396 |
@st.cache_resource
|
397 |
def get_table_download_link(file_path):
|
@@ -1378,7 +1395,7 @@ What is SORA?
|
|
1378 |
#example_input = st.text_input("Enter your prompt text:", value=prompt, help="Enter text to get a response.")
|
1379 |
#example_input = st.text_area("Enter Prompt :", '', height=100
|
1380 |
|
1381 |
-
# Search History
|
1382 |
session_state = {}
|
1383 |
if "search_queries" not in session_state:
|
1384 |
session_state["search_queries"] = []
|
@@ -1388,12 +1405,10 @@ What is SORA?
|
|
1388 |
|
1389 |
# Search AI
|
1390 |
query=example_input
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
except:
|
1396 |
-
st.markdown(' ')
|
1397 |
|
1398 |
st.write("Search history:")
|
1399 |
for example_input in session_state["search_queries"]:
|
|
|
79 |
with open(file_name, "r") as file:
|
80 |
content = file.read()
|
81 |
return content
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
#import streamlit as st
|
87 |
#from gradio_client import Client
|
88 |
#client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
|
|
95 |
#)
|
96 |
#st.markdown(result)
|
97 |
|
98 |
+
|
99 |
+
|
100 |
+
|
101 |
+
# HTML5 based Speech Synthesis (Text to Speech in Browser)
|
102 |
+
@st.cache_resource
|
103 |
+
def SpeechSynthesis(result):
|
104 |
+
documentHTML5='''
|
105 |
+
<!DOCTYPE html>
|
106 |
+
<html>
|
107 |
+
<head>
|
108 |
+
<title>Read It Aloud</title>
|
109 |
+
<script type="text/javascript">
|
110 |
+
function readAloud() {
|
111 |
+
const text = document.getElementById("textArea").value;
|
112 |
+
const speech = new SpeechSynthesisUtterance(text);
|
113 |
+
window.speechSynthesis.speak(speech);
|
114 |
+
}
|
115 |
+
</script>
|
116 |
+
</head>
|
117 |
+
<body>
|
118 |
+
<h1>π Read It Aloud</h1>
|
119 |
+
<textarea id="textArea" rows="10" cols="80">
|
120 |
+
'''
|
121 |
+
documentHTML5 = documentHTML5 + result
|
122 |
+
documentHTML5 = documentHTML5 + '''
|
123 |
+
</textarea>
|
124 |
+
<br>
|
125 |
+
<button onclick="readAloud()">π Read Aloud</button>
|
126 |
+
</body>
|
127 |
+
</html>
|
128 |
+
'''
|
129 |
+
components.html(documentHTML5, width=1280, height=300)
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
def search_arxiv(query):
|
135 |
st.title("βΆοΈ Semantic and Episodic Memory System")
|
136 |
|
|
|
152 |
)
|
153 |
|
154 |
# Show ArXiv Scholary Articles! ----------------*************-------------***************----------------------------------------
|
155 |
+
|
156 |
st.markdown(result)
|
157 |
+
|
158 |
+
|
159 |
+
arxiv_results = st.text_area("ArXiv Results: ", value=result, height=700)
|
160 |
+
|
161 |
+
|
162 |
SpeechSynthesis(result) # Search History Reader / Writer IO Memory - Audio at Same time as Reading.
|
163 |
|
164 |
+
|
165 |
+
# Show ArXiv Scholary Articles! ----------------*************-------------***************----------------------------------------
|
166 |
+
|
167 |
filename=generate_filename(result, "md")
|
168 |
base_filename, ext = os.path.splitext(filename)
|
169 |
with open(f"{base_filename}.md", 'w') as file:
|
|
|
185 |
|
186 |
|
187 |
create_file(filename, query, result, should_save)
|
|
|
188 |
|
189 |
|
190 |
file_type = st.radio("Select Which Type of Memory You Prefer:", ("Semantic", "Episodic"))
|
|
|
409 |
|
410 |
|
411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
|
413 |
@st.cache_resource
|
414 |
def get_table_download_link(file_path):
|
|
|
1395 |
#example_input = st.text_input("Enter your prompt text:", value=prompt, help="Enter text to get a response.")
|
1396 |
#example_input = st.text_area("Enter Prompt :", '', height=100
|
1397 |
|
1398 |
+
# Search History to ArXiv
|
1399 |
session_state = {}
|
1400 |
if "search_queries" not in session_state:
|
1401 |
session_state["search_queries"] = []
|
|
|
1405 |
|
1406 |
# Search AI
|
1407 |
query=example_input
|
1408 |
+
if query:
|
1409 |
+
search_arxiv(query)
|
1410 |
+
search_glossary(query)
|
1411 |
+
st.markdown(' ')
|
|
|
|
|
1412 |
|
1413 |
st.write("Search history:")
|
1414 |
for example_input in session_state["search_queries"]:
|