Spaces:
Paused
Paused
update
Browse files- app.py +13 -7
- assets/Claude.png +0 -0
- assets/user.png +0 -0
app.py
CHANGED
@@ -24,8 +24,10 @@ custom_css = """
|
|
24 |
div#component-4 #chatbot {
|
25 |
height: 800px !important;
|
26 |
}
|
|
|
27 |
"""
|
28 |
|
|
|
29 |
def replace_texttt(text):
|
30 |
return re.sub(r"\\texttt\{(.*?)\}", r"*\1*", text)
|
31 |
|
@@ -41,8 +43,8 @@ def get_paper_info(paper_id):
|
|
41 |
# Return the paper's title and abstract
|
42 |
# remove new lines
|
43 |
title_ = paper.title.replace("\n", " ").replace("\r", " ")
|
44 |
-
summary_
|
45 |
-
return
|
46 |
else:
|
47 |
return None, None
|
48 |
|
@@ -51,7 +53,7 @@ def get_paper_from_huggingface(paper_id):
|
|
51 |
try:
|
52 |
url = f"https://huggingface.co/datasets/taesiri/arxiv_db/raw/main/papers/{paper_id}.tex"
|
53 |
response = requests.get(url)
|
54 |
-
response.raise_for_status()
|
55 |
return response.text
|
56 |
except Exception as e:
|
57 |
return None
|
@@ -214,7 +216,9 @@ def clear_context():
|
|
214 |
return []
|
215 |
|
216 |
|
217 |
-
with gr.Blocks(
|
|
|
|
|
218 |
gr.HTML(
|
219 |
"""
|
220 |
<h1 style='text-align: center; font-size: 24px;'>
|
@@ -246,7 +250,10 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
|
246 |
|
247 |
with gr.Row().style(equal_height=False):
|
248 |
with gr.Column(scale=2, emem_id="column-flex"):
|
249 |
-
chatbot = gr.Chatbot(
|
|
|
|
|
|
|
250 |
|
251 |
with gr.Column(scale=1):
|
252 |
paper_id_input = gr.Textbox(label="Enter Paper ID", value="2310.12103")
|
@@ -260,8 +267,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
|
260 |
btn_answer = gr.Button("Answer Question")
|
261 |
btn_clear = gr.Button("Clear Chat")
|
262 |
|
263 |
-
|
264 |
-
|
265 |
gr.HTML(
|
266 |
"""<center>All the inputs are being sent to Anthropic's Claude endpoints. Please refer to <a href="https://legal.anthropic.com/#privacy">this link</a> for privacy policy.</center>"""
|
267 |
)
|
@@ -288,5 +293,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
|
288 |
|
289 |
btn_clear.click(clear_context, outputs=[chatbot])
|
290 |
|
|
|
291 |
app.mount("/js", StaticFiles(directory="js"), name="js")
|
292 |
gr.mount_gradio_app(app, demo, path="/")
|
|
|
24 |
div#component-4 #chatbot {
|
25 |
height: 800px !important;
|
26 |
}
|
27 |
+
|
28 |
"""
|
29 |
|
30 |
+
|
31 |
def replace_texttt(text):
|
32 |
return re.sub(r"\\texttt\{(.*?)\}", r"*\1*", text)
|
33 |
|
|
|
43 |
# Return the paper's title and abstract
|
44 |
# remove new lines
|
45 |
title_ = paper.title.replace("\n", " ").replace("\r", " ")
|
46 |
+
summary_ = paper.summary.replace("\n", " ").replace("\r", " ")
|
47 |
+
return title_, summary_
|
48 |
else:
|
49 |
return None, None
|
50 |
|
|
|
53 |
try:
|
54 |
url = f"https://huggingface.co/datasets/taesiri/arxiv_db/raw/main/papers/{paper_id}.tex"
|
55 |
response = requests.get(url)
|
56 |
+
response.raise_for_status()
|
57 |
return response.text
|
58 |
except Exception as e:
|
59 |
return None
|
|
|
216 |
return []
|
217 |
|
218 |
|
219 |
+
with gr.Blocks(
|
220 |
+
theme=gr.themes.Soft(), css=custom_css, title="ArXiv QA with Claude"
|
221 |
+
) as demo:
|
222 |
gr.HTML(
|
223 |
"""
|
224 |
<h1 style='text-align: center; font-size: 24px;'>
|
|
|
250 |
|
251 |
with gr.Row().style(equal_height=False):
|
252 |
with gr.Column(scale=2, emem_id="column-flex"):
|
253 |
+
chatbot = gr.Chatbot(
|
254 |
+
elem_id="chatbot",
|
255 |
+
avatar_images=("./assets/user.png", "./assets/Claude.png"),
|
256 |
+
)
|
257 |
|
258 |
with gr.Column(scale=1):
|
259 |
paper_id_input = gr.Textbox(label="Enter Paper ID", value="2310.12103")
|
|
|
267 |
btn_answer = gr.Button("Answer Question")
|
268 |
btn_clear = gr.Button("Clear Chat")
|
269 |
|
|
|
|
|
270 |
gr.HTML(
|
271 |
"""<center>All the inputs are being sent to Anthropic's Claude endpoints. Please refer to <a href="https://legal.anthropic.com/#privacy">this link</a> for privacy policy.</center>"""
|
272 |
)
|
|
|
293 |
|
294 |
btn_clear.click(clear_context, outputs=[chatbot])
|
295 |
|
296 |
+
|
297 |
app.mount("/js", StaticFiles(directory="js"), name="js")
|
298 |
gr.mount_gradio_app(app, demo, path="/")
|
assets/Claude.png
ADDED
assets/user.png
ADDED