Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -145,14 +145,14 @@ def generate_html(local_files):
|
|
145 |
html += "</ul>"
|
146 |
return html
|
147 |
|
148 |
-
|
149 |
def search_arxiv(query):
|
150 |
start_time = time.strftime("%Y-%m-%d %H:%M:%S")
|
151 |
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
152 |
search_query = query
|
153 |
search_source = "Arxiv Search - Latest - (EXPERIMENTAL)"
|
154 |
llm_model = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
155 |
-
st.markdown('### 🔎 ' + query)
|
156 |
|
157 |
# Search 1 - Retrieve the Papers
|
158 |
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
@@ -165,18 +165,19 @@ def search_arxiv(query):
|
|
165 |
)
|
166 |
lastpart = ''
|
167 |
totalparts = ''
|
168 |
-
results = response1[0] # Format for markdown display with links
|
169 |
-
results2 = response1[1] # format for subquery without links
|
170 |
-
st.markdown(results)
|
171 |
|
172 |
-
#
|
173 |
-
|
|
|
174 |
|
175 |
-
#
|
176 |
-
# local_links_html = download_pdfs_and_generate_html(urls)
|
177 |
-
st.markdown(urls)
|
178 |
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
180 |
if RunSecondQuery:
|
181 |
# Search 2 - Retrieve the Summary with Papers Context and Original Query
|
182 |
response2 = client.predict(
|
@@ -185,11 +186,18 @@ def search_arxiv(query):
|
|
185 |
True,
|
186 |
api_name="/ask_llm"
|
187 |
)
|
188 |
-
st.markdown(response2)
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
st.write('🔍Run of Multi-Agent System Paper Summary Spec is Complete')
|
192 |
end_time = time.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
193 |
start_timestamp = time.mktime(time.strptime(start_time, "%Y-%m-%d %H:%M:%S"))
|
194 |
end_timestamp = time.mktime(time.strptime(end_time, "%Y-%m-%d %H:%M:%S"))
|
195 |
elapsed_seconds = end_timestamp - start_timestamp
|
@@ -197,7 +205,8 @@ def search_arxiv(query):
|
|
197 |
st.write(f"Finish time: {end_time}")
|
198 |
st.write(f"Elapsed time: {elapsed_seconds:.2f} seconds")
|
199 |
|
200 |
-
|
|
|
201 |
filename = generate_filename(query, "md")
|
202 |
create_file(filename, query, results, should_save)
|
203 |
|
@@ -436,15 +445,15 @@ def display_glossary_entity(k):
|
|
436 |
def display_glossary_grid(roleplaying_glossary):
|
437 |
search_urls = {
|
438 |
"🚀🌌ArXiv": lambda k: f"/?q={quote(k)}", # this url plus query!
|
|
|
|
|
|
|
439 |
"📖Wiki": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
|
440 |
"🔍Google": lambda k: f"https://www.google.com/search?q={quote(k)}",
|
441 |
"▶️YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
442 |
"🔎Bing": lambda k: f"https://www.bing.com/search?q={quote(k)}",
|
443 |
"🎥YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
444 |
"🐦Twitter": lambda k: f"https://twitter.com/search?q={quote(k)}",
|
445 |
-
"🃏Analyst": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix)}", # this url plus query!
|
446 |
-
"📚PyCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix2)}", # this url plus query!
|
447 |
-
"🔬JSCoder": lambda k: f"https://huggingface.co/spaces/awacke1/{Site_Name}?q={quote(k)}-{quote(PromptPrefix3)}", # this url plus query!
|
448 |
}
|
449 |
|
450 |
for category, details in roleplaying_glossary.items():
|
|
|
145 |
html += "</ul>"
|
146 |
return html
|
147 |
|
148 |
+
#@st.cache_resource
|
149 |
def search_arxiv(query):
|
150 |
start_time = time.strftime("%Y-%m-%d %H:%M:%S")
|
151 |
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
152 |
search_query = query
|
153 |
search_source = "Arxiv Search - Latest - (EXPERIMENTAL)"
|
154 |
llm_model = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
155 |
+
#st.markdown('### 🔎 ' + query)
|
156 |
|
157 |
# Search 1 - Retrieve the Papers
|
158 |
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
|
|
165 |
)
|
166 |
lastpart = ''
|
167 |
totalparts = ''
|
|
|
|
|
|
|
168 |
|
169 |
+
Question = '### 🔎 ' + query + '\r\n' # Format for markdown display with links
|
170 |
+
References = response1[0]
|
171 |
+
References2 = response1[1]
|
172 |
|
173 |
+
#st.markdown(results)
|
|
|
|
|
174 |
|
175 |
+
# URLs from the response
|
176 |
+
ReferenceLinks = extract_urls(References)
|
177 |
+
#st.markdown(urls)
|
178 |
+
#results = results + urls
|
179 |
+
|
180 |
+
RunSecondQuery = True
|
181 |
if RunSecondQuery:
|
182 |
# Search 2 - Retrieve the Summary with Papers Context and Original Query
|
183 |
response2 = client.predict(
|
|
|
186 |
True,
|
187 |
api_name="/ask_llm"
|
188 |
)
|
189 |
+
#st.markdown(response2)
|
190 |
+
if len(response2) > 10:
|
191 |
+
Answer = response2
|
192 |
+
SpeechSynthesis(Answer)
|
193 |
+
# Restructure results to follow format of Question, Answer, References, ReferenceLinks
|
194 |
+
results = Question + Answer + References + ReferenceLinks
|
195 |
+
st.markdown(results)
|
196 |
|
197 |
st.write('🔍Run of Multi-Agent System Paper Summary Spec is Complete')
|
198 |
end_time = time.strftime("%Y-%m-%d %H:%M:%S")
|
199 |
+
|
200 |
+
# Output
|
201 |
start_timestamp = time.mktime(time.strptime(start_time, "%Y-%m-%d %H:%M:%S"))
|
202 |
end_timestamp = time.mktime(time.strptime(end_time, "%Y-%m-%d %H:%M:%S"))
|
203 |
elapsed_seconds = end_timestamp - start_timestamp
|
|
|
205 |
st.write(f"Finish time: {end_time}")
|
206 |
st.write(f"Elapsed time: {elapsed_seconds:.2f} seconds")
|
207 |
|
208 |
+
|
209 |
+
#SpeechSynthesis(results)
|
210 |
filename = generate_filename(query, "md")
|
211 |
create_file(filename, query, results, should_save)
|
212 |
|
|
|
445 |
def display_glossary_grid(roleplaying_glossary):
|
446 |
search_urls = {
|
447 |
"🚀🌌ArXiv": lambda k: f"/?q={quote(k)}", # this url plus query!
|
448 |
+
"🃏Analyst": lambda k: f"/?q={quote(k)}-{quote(PromptPrefix)}", # this url plus query!
|
449 |
+
"📚PyCoder": lambda k: f"/?q={quote(k)}-{quote(PromptPrefix2)}", # this url plus query!
|
450 |
+
"🔬JSCoder": lambda k: f"/?q={quote(k)}-{quote(PromptPrefix3)}", # this url plus query!
|
451 |
"📖Wiki": lambda k: f"https://en.wikipedia.org/wiki/{quote(k)}",
|
452 |
"🔍Google": lambda k: f"https://www.google.com/search?q={quote(k)}",
|
453 |
"▶️YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
454 |
"🔎Bing": lambda k: f"https://www.bing.com/search?q={quote(k)}",
|
455 |
"🎥YouTube": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}",
|
456 |
"🐦Twitter": lambda k: f"https://twitter.com/search?q={quote(k)}",
|
|
|
|
|
|
|
457 |
}
|
458 |
|
459 |
for category, details in roleplaying_glossary.items():
|