Update app.py
Browse files
app.py
CHANGED
|
@@ -33,8 +33,8 @@ except:
|
|
| 33 |
gr.Warning("Retriever not working!")
|
| 34 |
|
| 35 |
## Header
|
| 36 |
-
mark_text = '#
|
| 37 |
-
header_text = "
|
| 38 |
|
| 39 |
try:
|
| 40 |
with open("README.md", "r") as f:
|
|
@@ -53,7 +53,7 @@ database_choices = [index_info,'Arxiv Search - Latest - (EXPERIMENTAL)']
|
|
| 53 |
## Arxiv API
|
| 54 |
arx_client = arxiv.Client()
|
| 55 |
is_arxiv_available = True
|
| 56 |
-
check_arxiv_result = get_arxiv_live_search("What is
|
| 57 |
if len(check_arxiv_result) == 0:
|
| 58 |
is_arxiv_available = False
|
| 59 |
print("Arxiv search not working, switching to default search ...")
|
|
@@ -100,6 +100,35 @@ def get_references(question, retriever, k = retrieve_results):
|
|
| 100 |
def get_rag(message):
|
| 101 |
return get_references(message, RAG)
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
| 104 |
header = gr.Markdown(header_text)
|
| 105 |
|
|
@@ -173,6 +202,7 @@ with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
|
| 173 |
if stream_outputs:
|
| 174 |
for response in stream:
|
| 175 |
output += response
|
|
|
|
| 176 |
yield output
|
| 177 |
return output
|
| 178 |
else:
|
|
|
|
| 33 |
gr.Warning("Retriever not working!")
|
| 34 |
|
| 35 |
## Header
|
| 36 |
+
mark_text = '# 🩺🔍 Search Results\n'
|
| 37 |
+
header_text = "## Arxiv Paper Summary With QA Retrieval Augmented Generation \n"
|
| 38 |
|
| 39 |
try:
|
| 40 |
with open("README.md", "r") as f:
|
|
|
|
| 53 |
## Arxiv API
|
| 54 |
arx_client = arxiv.Client()
|
| 55 |
is_arxiv_available = True
|
| 56 |
+
check_arxiv_result = get_arxiv_live_search("What is Self Rewarding AI and how can it be used in Multi-Agent Systems?", arx_client, retrieve_results)
|
| 57 |
if len(check_arxiv_result) == 0:
|
| 58 |
is_arxiv_available = False
|
| 59 |
print("Arxiv search not working, switching to default search ...")
|
|
|
|
| 100 |
def get_rag(message):
|
| 101 |
return get_references(message, RAG)
|
| 102 |
|
| 103 |
+
def SaveResponseAndRead(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 |
+
gr.HTML(documentHTML5)
|
| 130 |
+
|
| 131 |
+
|
| 132 |
with gr.Blocks(theme = gr.themes.Soft()) as demo:
|
| 133 |
header = gr.Markdown(header_text)
|
| 134 |
|
|
|
|
| 202 |
if stream_outputs:
|
| 203 |
for response in stream:
|
| 204 |
output += response
|
| 205 |
+
SaveResponseAndRead(response)
|
| 206 |
yield output
|
| 207 |
return output
|
| 208 |
else:
|