chansung commited on
Commit
e08d6ea
β€’
1 Parent(s): ae265c6
Files changed (5) hide show
  1. app.py +29 -34
  2. background.py +13 -2
  3. constants/styles.css +199 -0
  4. init.py +1 -1
  5. ui.py +14 -10
app.py CHANGED
@@ -3,7 +3,6 @@ import gradio as gr
3
  from init import get_secrets, initialize_data, update_dataframe
4
  from gen.openllm import GradioLLaMA2ChatPPManager, GradioMistralChatPPManager
5
  from gen.gemini_chat import GradioGeminiChatPPManager
6
- from constants.styles import STYLE
7
  from constants.js import (
8
  UPDATE_SEARCH_RESULTS, OPEN_CHAT_IF,
9
  CLOSE_CHAT_IF, UPDATE_CHAT_HISTORY
@@ -31,7 +30,7 @@ last_day = sorted_day[-1]
31
  last_papers = date_dict[last_year][last_month][last_day]
32
  selected_paper = last_papers[0]
33
 
34
- with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
35
  cur_arxiv_id = gr.Textbox(selected_paper['arxiv_id'], visible=False)
36
  local_data = gr.JSON({}, visible=False)
37
  chat_state = gr.State({
@@ -88,14 +87,11 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
88
  # with gr.Row():
89
  with gr.Row():
90
  arxiv_link = gr.Markdown(
91
- "[![arXiv](https://img.shields.io/badge/arXiv-%s-b31b1b.svg?style=for-the-badge)](https://arxiv.org/abs/%s)" % (selected_paper['arxiv_id'], selected_paper['arxiv_id']),
92
- elem_classes=["markdown-center"]
 
93
  )
94
- hf_paper_link = gr.Markdown(
95
- "[![Paper page](https://huggingface.co/datasets/huggingface/badges/resolve/main/paper-page-lg.svg)](https://huggingface.co/papers/%s)" % selected_paper['arxiv_id'],
96
- elem_classes=["markdown-center"]
97
- )
98
- chat_button = gr.Button("πŸ’¬ about paper", interactive=True, elem_id="chat-button")
99
 
100
  summary = gr.Markdown(f"{selected_paper['summary']}", elem_classes=["small-font"])
101
 
@@ -154,23 +150,21 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
154
  breath_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
155
  breath_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
156
 
157
- with gr.Column(visible=True):
158
- gr.Markdown("## Request any arXiv ids")
159
- arxiv_queue = gr.Dataframe(
160
- headers=["Requested arXiv IDs"], col_count=(1, "fixed"),
161
- value=requested_arxiv_ids_df,
162
- datatype=["str"],
163
- interactive=False,
164
- )
165
-
166
- arxiv_id_enter = gr.Textbox(placeholder="Enter comma separated arXiv IDs...", elem_classes=["textbox-no-label"])
167
- arxiv_id_enter.submit(
168
- add_arxiv_ids_to_queue,
169
- [arxiv_queue, arxiv_id_enter],
170
- [arxiv_queue, arxiv_id_enter],
171
- concurrency_limit=20,
172
- )
173
-
174
 
175
  gr.Markdown("The target papers are collected from [Hugging Face πŸ€— Daily Papers](https://huggingface.co/papers) on a daily basis. "
176
  "The entire data is generated by [Google's Gemini 1.0](https://deepmind.google/technologies/gemini/) Pro. "
@@ -251,7 +245,7 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
251
  set_paper, [year_dd, month_dd, day_dd, papers_dd],
252
  [
253
  cur_arxiv_id,
254
- title, arxiv_link, hf_paper_link, summary,
255
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
256
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
257
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
@@ -271,7 +265,7 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
271
  set_paper, [year_dd, month_dd, day_dd, papers_dd],
272
  [
273
  cur_arxiv_id,
274
- title, arxiv_link, hf_paper_link, summary,
275
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
276
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
277
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
@@ -284,14 +278,14 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
284
  depth_q_2, depth_q_eli5_2, depth_q_expert_2,
285
  breath_q_2, breath_q_eli5_2, breath_q_expert_2
286
  ],
287
- concurrency_limit=20,
288
  )
289
 
290
  day_dd.input(get_paper_by_day, inputs=[year_dd, month_dd, day_dd], outputs=[papers_dd]).then(
291
  set_paper, [year_dd, month_dd, day_dd, papers_dd],
292
  [
293
  cur_arxiv_id,
294
- title, arxiv_link, hf_paper_link, summary,
295
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
296
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
297
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
@@ -310,7 +304,7 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
310
  papers_dd.change(set_paper, [year_dd, month_dd, day_dd, papers_dd],
311
  [
312
  cur_arxiv_id,
313
- title, arxiv_link, hf_paper_link, summary,
314
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
315
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
316
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
@@ -343,7 +337,8 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
343
  basic_q_eli5_0, basic_q_expert_0, depth_q_eli5_0, depth_q_expert_0, breath_q_eli5_0, breath_q_expert_0,
344
  basic_q_eli5_1, basic_q_expert_1, depth_q_eli5_1, depth_q_expert_1, breath_q_eli5_1, breath_q_expert_1,
345
  basic_q_eli5_2, basic_q_expert_2, depth_q_eli5_2, depth_q_expert_2, breath_q_eli5_2, breath_q_expert_2
346
- ]
 
347
  )
348
 
349
  chat_button.click(None, [cur_arxiv_id], [local_data, chatbot], js=OPEN_CHAT_IF)
@@ -375,7 +370,7 @@ with gr.Blocks(css=STYLE, theme=gr.themes.Soft()) as demo:
375
  js=UPDATE_CHAT_HISTORY
376
  )
377
 
378
- demo.load(lambda: update_dataframe(request_arxiv_repo_id), None, arxiv_queue, every=360)
379
  # demo.load(None, None, [chatbot, local_data], js=GET_LOCAL_STORAGE % idx.value)
380
 
381
  start_date = datetime.now() + timedelta(minutes=1)
@@ -399,5 +394,5 @@ demo.queue(
399
  default_concurrency_limit=20,
400
  max_size=256
401
  ).launch(
402
- debug=True
403
  )
 
3
  from init import get_secrets, initialize_data, update_dataframe
4
  from gen.openllm import GradioLLaMA2ChatPPManager, GradioMistralChatPPManager
5
  from gen.gemini_chat import GradioGeminiChatPPManager
 
6
  from constants.js import (
7
  UPDATE_SEARCH_RESULTS, OPEN_CHAT_IF,
8
  CLOSE_CHAT_IF, UPDATE_CHAT_HISTORY
 
30
  last_papers = date_dict[last_year][last_month][last_day]
31
  selected_paper = last_papers[0]
32
 
33
+ with gr.Blocks(css="constants/styles.css", theme=gr.themes.Soft()) as demo:
34
  cur_arxiv_id = gr.Textbox(selected_paper['arxiv_id'], visible=False)
35
  local_data = gr.JSON({}, visible=False)
36
  chat_state = gr.State({
 
87
  # with gr.Row():
88
  with gr.Row():
89
  arxiv_link = gr.Markdown(
90
+ "[![arXiv](https://img.shields.io/badge/arXiv-%s-b31b1b.svg?style=for-the-badge)](https://arxiv.org/abs/%s)" % (selected_paper['arxiv_id'], selected_paper['arxiv_id']) + " "
91
+ "[![Paper page](https://huggingface.co/datasets/huggingface/badges/resolve/main/paper-page-lg.svg)](https://huggingface.co/papers/%s)" % selected_paper['arxiv_id'] + " ",
92
+ elem_id="link-md",
93
  )
94
+ chat_button = gr.Button("Chat about any custom questions", interactive=True, elem_id="chat-button")
 
 
 
 
95
 
96
  summary = gr.Markdown(f"{selected_paper['summary']}", elem_classes=["small-font"])
97
 
 
150
  breath_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
151
  breath_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
152
 
153
+ gr.Markdown("## Request any arXiv ids")
154
+ arxiv_queue = gr.Dataframe(
155
+ headers=["Requested arXiv IDs"], col_count=(1, "fixed"),
156
+ value=requested_arxiv_ids_df,
157
+ datatype=["str"],
158
+ interactive=False,
159
+ )
160
+
161
+ arxiv_id_enter = gr.Textbox(placeholder="Enter comma separated arXiv IDs...", elem_classes=["textbox-no-label"])
162
+ arxiv_id_enter.submit(
163
+ add_arxiv_ids_to_queue,
164
+ [arxiv_queue, arxiv_id_enter],
165
+ [arxiv_queue, arxiv_id_enter],
166
+ concurrency_limit=20,
167
+ )
 
 
168
 
169
  gr.Markdown("The target papers are collected from [Hugging Face πŸ€— Daily Papers](https://huggingface.co/papers) on a daily basis. "
170
  "The entire data is generated by [Google's Gemini 1.0](https://deepmind.google/technologies/gemini/) Pro. "
 
245
  set_paper, [year_dd, month_dd, day_dd, papers_dd],
246
  [
247
  cur_arxiv_id,
248
+ title, arxiv_link, summary,
249
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
250
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
251
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
 
265
  set_paper, [year_dd, month_dd, day_dd, papers_dd],
266
  [
267
  cur_arxiv_id,
268
+ title, arxiv_link, summary,
269
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
270
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
271
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
 
278
  depth_q_2, depth_q_eli5_2, depth_q_expert_2,
279
  breath_q_2, breath_q_eli5_2, breath_q_expert_2
280
  ],
281
+ concurrency_limit=20,
282
  )
283
 
284
  day_dd.input(get_paper_by_day, inputs=[year_dd, month_dd, day_dd], outputs=[papers_dd]).then(
285
  set_paper, [year_dd, month_dd, day_dd, papers_dd],
286
  [
287
  cur_arxiv_id,
288
+ title, arxiv_link, summary,
289
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
290
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
291
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
 
304
  papers_dd.change(set_paper, [year_dd, month_dd, day_dd, papers_dd],
305
  [
306
  cur_arxiv_id,
307
+ title, arxiv_link, summary,
308
  basic_q_0, basic_q_eli5_0, basic_q_expert_0,
309
  depth_q_0, depth_q_eli5_0, depth_q_expert_0,
310
  breath_q_0, breath_q_eli5_0, breath_q_expert_0,
 
337
  basic_q_eli5_0, basic_q_expert_0, depth_q_eli5_0, depth_q_expert_0, breath_q_eli5_0, breath_q_expert_0,
338
  basic_q_eli5_1, basic_q_expert_1, depth_q_eli5_1, depth_q_expert_1, breath_q_eli5_1, breath_q_expert_1,
339
  basic_q_eli5_2, basic_q_expert_2, depth_q_eli5_2, depth_q_expert_2, breath_q_eli5_2, breath_q_expert_2
340
+ ],
341
+ concurrency_limit=20,
342
  )
343
 
344
  chat_button.click(None, [cur_arxiv_id], [local_data, chatbot], js=OPEN_CHAT_IF)
 
370
  js=UPDATE_CHAT_HISTORY
371
  )
372
 
373
+ demo.load(lambda: update_dataframe(request_arxiv_repo_id), None, arxiv_queue, every=180)
374
  # demo.load(None, None, [chatbot, local_data], js=GET_LOCAL_STORAGE % idx.value)
375
 
376
  start_date = datetime.now() + timedelta(minutes=1)
 
394
  default_concurrency_limit=20,
395
  max_size=256
396
  ).launch(
397
+ share=True, debug=True
398
  )
background.py CHANGED
@@ -18,6 +18,17 @@ def _filter_function(example, ids):
18
  print(example)
19
  return example
20
 
 
 
 
 
 
 
 
 
 
 
 
21
  def process_arxiv_ids(gemini_api, hf_repo_id, req_hf_repo_id, hf_token, restart_repo_id, how_many=10):
22
  arxiv_ids = []
23
 
@@ -25,7 +36,7 @@ def process_arxiv_ids(gemini_api, hf_repo_id, req_hf_repo_id, hf_token, restart_
25
  for d in ds1['train']:
26
  req_arxiv_ids = d['Requested arXiv IDs']
27
  if len(req_arxiv_ids) > 0 and req_arxiv_ids[0] != "top":
28
- arxiv_ids = arxiv_ids + req_arxiv_ids
29
 
30
  arxiv_ids = arxiv_ids[:how_many]
31
 
@@ -77,7 +88,7 @@ def process_arxiv_ids(gemini_api, hf_repo_id, req_hf_repo_id, hf_token, restart_
77
 
78
  print(f"......Updating request arXiv HF Dataset repo at [{req_hf_repo_id}]")
79
  ds1 = ds1['train'].map(
80
- lambda example: _filter_function(example, [arxiv_id])
81
  ).filter(
82
  lambda example: len(example['Requested arXiv IDs']) > 0
83
  )
 
18
  print(example)
19
  return example
20
 
21
+ def _extract_arxiv_id(text):
22
+ print(text)
23
+ start = text.find("[") + 1
24
+ end = text.find("]")
25
+
26
+ # Extract the text between brackets
27
+ if start != -1 and end != -1:
28
+ return text[start:end]
29
+ else:
30
+ return text
31
+
32
  def process_arxiv_ids(gemini_api, hf_repo_id, req_hf_repo_id, hf_token, restart_repo_id, how_many=10):
33
  arxiv_ids = []
34
 
 
36
  for d in ds1['train']:
37
  req_arxiv_ids = d['Requested arXiv IDs']
38
  if len(req_arxiv_ids) > 0 and req_arxiv_ids[0] != "top":
39
+ arxiv_ids = arxiv_ids + [_extract_arxiv_id(req_arxiv_ids[0])]
40
 
41
  arxiv_ids = arxiv_ids[:how_many]
42
 
 
88
 
89
  print(f"......Updating request arXiv HF Dataset repo at [{req_hf_repo_id}]")
90
  ds1 = ds1['train'].map(
91
+ lambda example: _filter_function(example, [f"[{arxiv_id}] {title}"])
92
  ).filter(
93
  lambda example: len(example['Requested arXiv IDs']) > 0
94
  )
constants/styles.css ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .main {
2
+ @media only screen and (min-width: 1000px) {
3
+ width: 70% !important;
4
+ margin: 0 auto; /* Center the container */
5
+ }
6
+ }
7
+
8
+ .small-font{
9
+ font-size: 12pt !important;
10
+ transition: font-size 0.4s ease-out;
11
+ transition-delay: 0.8s;
12
+ }
13
+
14
+ .small-font:hover {
15
+ font-size: 20px !important;
16
+ transition: font-size 0.3s ease-out;
17
+ transition-delay: 1.5s;
18
+ }
19
+
20
+ .group {
21
+ padding-top: 10px;
22
+ padding-left: 10px;
23
+ padding-right: 10px;
24
+ padding-bottom: 10px;
25
+ border: 2px dashed gray;
26
+ border-radius: 20px;
27
+ box-shadow: 5px 3px 10px 1px rgba(0, 0, 0, 0.4) !important;
28
+ }
29
+
30
+ .accordion > button > span{
31
+ font-size: 12pt !important;
32
+ }
33
+
34
+ .accordion {
35
+ border-style: dashed !important;
36
+ border-left-width: 2px !important;
37
+ border-bottom-width: 2.5px !important;
38
+ border-top: none !important;
39
+ border-right: none !important;
40
+ box-shadow: none !important;
41
+ }
42
+
43
+ .no-gap {
44
+ gap: 0px;
45
+ }
46
+
47
+ .no-radius {
48
+ border-radius: 0px;
49
+ }
50
+
51
+ .textbox-no-label > label > span {
52
+ display: none;
53
+ }
54
+
55
+ .exp-type > span {
56
+ display: none;
57
+ }
58
+
59
+ .conv-type > span {
60
+ display: none;
61
+ }
62
+
63
+ .conv-type .wrap:nth-child(3) {
64
+ width: 167px;
65
+ margin: auto;
66
+ }
67
+
68
+ button {
69
+ font-size: 10pt !important;
70
+ }
71
+
72
+ h3 {
73
+ font-size: 13pt !important;
74
+ }
75
+
76
+ #control-panel {
77
+ margin-bottom: 30px;
78
+ }
79
+
80
+ #chatbot {
81
+ background-color: white;
82
+ border: 1px solid #ccc;
83
+ padding: 20px;
84
+ box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.3);
85
+ border-radius: 30px;
86
+ height: 80%;
87
+ width: 80%;
88
+
89
+ position: fixed;
90
+ top: 50%;
91
+ left: 50%;
92
+ transform: translate(-50%, -50%);
93
+ z-index: 1000; /* Or a high enough value to stay on top */
94
+
95
+ @media (max-width: 768px) { /* Adjust this breakpoint as needed */
96
+ width: 95%;
97
+ }
98
+
99
+ @media (prefers-color-scheme: dark) {
100
+ background-color: dimgrey;
101
+ }
102
+ }
103
+
104
+ #chat-button {
105
+ border-radius: 30px;
106
+ font-size: 13pt !important;
107
+
108
+ @media only screen and (min-width: 500px) {
109
+ font-size: 10pt;
110
+ margin: auto; /* Center the container */
111
+ }
112
+ }
113
+
114
+ #chatbot-inside {
115
+ height: 100% !important;
116
+ border-width: 1px !important;
117
+ border-color: lightgray !important;
118
+ }
119
+
120
+ #chatbot-txtbox {
121
+ padding-bottom: 25px;
122
+ }
123
+
124
+ #chatbot-bottm {
125
+ padding-left: 10px;
126
+ padding-right: 10px;
127
+ }
128
+
129
+ #chatbot-right-button {
130
+ float: right;
131
+ width: 20px;
132
+ font-size: 17pt;
133
+ }
134
+
135
+ #chatbot-info {
136
+ word-break: break-word;
137
+ }
138
+
139
+ #chatbot-back {
140
+ position: absolute; /* Stay in place even when scrolling */
141
+ z-index: 1000; /* Ensure it's on top of everything else */
142
+ width: 100%;
143
+ height: 100%;
144
+ left: 0px;
145
+ top: 0px;
146
+
147
+ opacity: 0;
148
+ visibility: hidden; /* Ensures the element is not interactive */
149
+ transition: opacity 0.5s ease, visibility 0s 0.5s; /* Transition for opacity and delay visibility */
150
+ }
151
+
152
+ #chatbot-back.visible {
153
+ opacity: 1;
154
+ visibility: visible; /* Now visible and interactive */
155
+ transition: opacity 0.5s ease; /* Smooth transition for opacity */
156
+ }
157
+
158
+ .hover-opacity {
159
+ opacity: 0.8; /* Normal opacity of the element */
160
+ transition: opacity 0.3s ease-in-out; /* Smooth opacity change */
161
+ }
162
+
163
+ .hover-opacity:hover {
164
+ opacity: 1; /* Full opacity on hover */
165
+ }
166
+
167
+ .markdown-center {
168
+ display: block;
169
+ text-align: center;
170
+ }
171
+
172
+ #link-md {
173
+ display: flex;
174
+ justify-content: space-around;
175
+ }
176
+
177
+ #link-md a {
178
+ display: inline-block;
179
+ vertical-align: middle;
180
+ }
181
+
182
+ #link-md a {
183
+ display: inline-block;
184
+ vertical-align: middle;
185
+ }
186
+
187
+ #link-md a:nth-child(1) {
188
+ margin-right: 10px;
189
+ @media only screen and (max-width: 1000px) {
190
+ margin-right: 0px;
191
+ }
192
+ }
193
+
194
+ #link-md a:nth-child(2) {
195
+ margin-left: 10px;
196
+ @media only screen and (max-width: 1000px) {
197
+ margin-left: 0px;
198
+ }
199
+ }
init.py CHANGED
@@ -57,7 +57,7 @@ def _initialize_paper_info(source_ds):
57
  arxivid2data[paper['arxiv_id']] = {"idx": count, "paper": paper}
58
  date_dict[year][month][day].append(paper)
59
 
60
- titles = title2qna.keys()
61
 
62
  return titles, date_dict, arxivid2data
63
 
 
57
  arxivid2data[paper['arxiv_id']] = {"idx": count, "paper": paper}
58
  date_dict[year][month][day].append(paper)
59
 
60
+ titles = [f"[{v['arxiv_id']}] {k}" for k, v in title2qna.items()]
61
 
62
  return titles, date_dict, arxivid2data
63
 
ui.py CHANGED
@@ -13,6 +13,8 @@ from gen.gemini_chat import gen_text as gemini_gen_text
13
  from gen.gemini_chat import init as gemini_init
14
  from constants.context import DEFAULT_GLOBAL_CTX
15
 
 
 
16
  from init import (
17
  requested_arxiv_ids_df,
18
  date_dict,
@@ -60,7 +62,10 @@ def get_paper_by_day(year, month, day):
60
  ))
61
  return gr.Dropdown(choices=papers, value=papers[0])
62
 
 
63
  def set_papers(year, month, day, title):
 
 
64
  papers = []
65
  for paper in date_dict[year][month][day]:
66
  papers.append(paper["title"])
@@ -82,15 +87,11 @@ def set_paper(year, month, day, paper_title):
82
  selected_paper = paper
83
  break
84
 
85
- print(type(selected_paper['arxiv_id']))
86
-
87
  return (
88
  selected_paper['arxiv_id'],
89
  gr.Markdown(f"# {selected_paper['title']}"),
90
  gr.Markdown(
91
- "[![arXiv](https://img.shields.io/badge/arXiv-%s-b31b1b.svg?style=for-the-badge)](https://arxiv.org/abs/%s)" % (selected_paper['arxiv_id'], selected_paper['arxiv_id'])
92
- ),
93
- gr.Markdown(
94
  "[![Paper page](https://huggingface.co/datasets/huggingface/badges/resolve/main/paper-page-lg.svg)](https://huggingface.co/papers/%s)" % selected_paper['arxiv_id']
95
  ),
96
  gr.Markdown(selected_paper["summary"]),
@@ -127,6 +128,8 @@ def set_paper(year, month, day, paper_title):
127
  )
128
 
129
  def set_date(title):
 
 
130
  for _, (year, months) in enumerate(date_dict.items()):
131
  for _, (month, days) in enumerate(months.items()):
132
  for _, (day, papers) in enumerate(days.items()):
@@ -195,8 +198,10 @@ def add_arxiv_ids_to_queue(queue, arxiv_ids_str):
195
  valid_arxiv_ids = _filter_duplicate_arxiv_ids(valid_arxiv_ids)
196
 
197
  if len(valid_arxiv_ids) > 0:
198
- valid_arxiv_ids = [[arxiv_id] for arxiv_id in valid_arxiv_ids]
199
- gr.Warning(f"Processing on [{valid_arxiv_ids}]. Other requested arXiv IDs not found on this list should be already processed or being processed...")
 
 
200
  valid_arxiv_ids = pd.DataFrame({'Requested arXiv IDs': valid_arxiv_ids})
201
  queue = pd.concat([queue, valid_arxiv_ids])
202
  queue.reset_index(drop=True)
@@ -254,13 +259,12 @@ async def chat_stream(idx, local_data, user_prompt, chat_state, ctx_num_lconv=3)
254
  async for result in gemini_gen_text(prompt):
255
  ppm.append_pong(result)
256
  yield "", ppm.build_uis(), str(ppm), gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)
257
-
258
  yield "", ppm.build_uis(), str(ppm), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
259
  except Exception as e:
260
- print(e)
261
  gr.Warning(str(e))
262
  ppm.replace_last_pong("Gemini refused to answer. This happens becase there were some safety issues in the answer.")
263
- yield "", ppm.build_uis(), str(ppm), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
264
 
265
  def chat_reset(local_data, chat_state):
266
  ppm = chat_state["ppmanager_type"].from_json(json.dumps(local_data))
 
13
  from gen.gemini_chat import init as gemini_init
14
  from constants.context import DEFAULT_GLOBAL_CTX
15
 
16
+ from paper.download import get_papers_from_arxiv_ids
17
+
18
  from init import (
19
  requested_arxiv_ids_df,
20
  date_dict,
 
62
  ))
63
  return gr.Dropdown(choices=papers, value=papers[0])
64
 
65
+ # 2307.02040
66
  def set_papers(year, month, day, title):
67
+ title = title.split("]")[1].strip()
68
+
69
  papers = []
70
  for paper in date_dict[year][month][day]:
71
  papers.append(paper["title"])
 
87
  selected_paper = paper
88
  break
89
 
 
 
90
  return (
91
  selected_paper['arxiv_id'],
92
  gr.Markdown(f"# {selected_paper['title']}"),
93
  gr.Markdown(
94
+ "[![arXiv](https://img.shields.io/badge/arXiv-%s-b31b1b.svg?style=for-the-badge)](https://arxiv.org/abs/%s)" % (selected_paper['arxiv_id'], selected_paper['arxiv_id']) + " "
 
 
95
  "[![Paper page](https://huggingface.co/datasets/huggingface/badges/resolve/main/paper-page-lg.svg)](https://huggingface.co/papers/%s)" % selected_paper['arxiv_id']
96
  ),
97
  gr.Markdown(selected_paper["summary"]),
 
128
  )
129
 
130
  def set_date(title):
131
+ title = title.split("]")[1].strip()
132
+
133
  for _, (year, months) in enumerate(date_dict.items()):
134
  for _, (month, days) in enumerate(months.items()):
135
  for _, (day, papers) in enumerate(days.items()):
 
198
  valid_arxiv_ids = _filter_duplicate_arxiv_ids(valid_arxiv_ids)
199
 
200
  if len(valid_arxiv_ids) > 0:
201
+ papers = get_papers_from_arxiv_ids(valid_arxiv_ids)
202
+ valid_arxiv_ids = [[f"[{paper['paper']['id']}] {paper['title']}"] for paper in papers]
203
+
204
+ gr.Warning(f"Processing [{valid_arxiv_ids}]. Other requested arXiv IDs not found on this list should be already processed or being processed...")
205
  valid_arxiv_ids = pd.DataFrame({'Requested arXiv IDs': valid_arxiv_ids})
206
  queue = pd.concat([queue, valid_arxiv_ids])
207
  queue.reset_index(drop=True)
 
259
  async for result in gemini_gen_text(prompt):
260
  ppm.append_pong(result)
261
  yield "", ppm.build_uis(), str(ppm), gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)
262
+
263
  yield "", ppm.build_uis(), str(ppm), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
264
  except Exception as e:
 
265
  gr.Warning(str(e))
266
  ppm.replace_last_pong("Gemini refused to answer. This happens becase there were some safety issues in the answer.")
267
+ yield "", ppm.build_uis(), str(ppm), gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
268
 
269
  def chat_reset(local_data, chat_state):
270
  ppm = chat_state["ppmanager_type"].from_json(json.dumps(local_data))