File size: 1,296 Bytes
1856658
 
a7b0da8
1856658
 
 
 
 
 
 
a7b0da8
 
 
 
ac15c4c
 
a7b0da8
 
1856658
 
a7b0da8
1856658
 
 
 
 
 
 
a7b0da8
c0650fa
1856658
a7b0da8
c0650fa
1856658
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import arxiv
from datasets import load_dataset

search = arxiv.Search(
    query = "cs.LG",
    max_results = 50,
    sort_by = arxiv.SortCriterion.SubmittedDate
)

#HF_TOKEN = os.getenv("HF_TOKEN") # might use in the future

def hf_data_upload(user_id, paper_id, feedback):
  new_row = {"user_id": user_id, "paper_id": paper_id, "feedback": feedback}
  ds = load_dataset("CShorten/Last-Week-on-ArXiv")["train"]
  ds = ds.add_item(new_row)
  ds.push_to_hub("CShorten/Last-Week-on-ArXiv") 

with gr.Blocks() as demo:
  gr.Markdown("<center><h1>My ArXiv</h1></center>")
  user_id = gr.Textbox(placeholder="Enter user id for personalization: ")
  with gr.Column():
    for arxiv_paper in search.results():
      with gr.Column():
        with gr.Column():
          gr.Markdown("<center><h3>" + arxiv_paper.title + "</h3></center>")
          gr.Markdown(arxiv_paper.summary)
        with gr.Row():
          more_button = gr.Button("More like this! 😎")
          more_button.click(hf_data_upload(str(user_id.value), arxiv_paper.title, 1))
          #button.click(flip_image, inputs=image_input, outputs=image_output)
          less_button = gr.Button("Less like this! πŸ˜•")
          less_button.click(hf_data_upload(str(user_id.value), arxiv_paper.title, 0))

demo.launch()