Spaces:
Runtime error
Runtime error
File size: 20,666 Bytes
928f123 e518ed3 7e4123a 928f123 7e4123a 928f123 ca3e112 7e4123a 4bad4d8 e518ed3 4bad4d8 4572f9c 7e4123a 4572f9c 1be7f01 af10ea5 1be7f01 ca3e112 e08d6ea 7e4123a ca3e112 7e4123a ca3e112 7e4123a 125abbd ba0d9a2 1c5a53b 046ea77 de51e8b 4572f9c 9ddd488 4572f9c 1c5a53b 64cc57f 1c5a53b c53af21 1c5a53b 928f123 1c5a53b 928f123 046ea77 7e4123a deee37e b080e86 e08d6ea b080e86 e08d6ea 66f4eb1 928f123 046ea77 ca3e112 c3d4cb6 ba0d9a2 4572f9c 1c5a53b 4572f9c 923e7bc a68da4c 1c5a53b 4572f9c 1c5a53b 4572f9c 923e7bc a68da4c 1c5a53b 4572f9c 1c5a53b 4572f9c 923e7bc a68da4c 1c5a53b 4572f9c 928f123 4572f9c 923e7bc a68da4c 928f123 4572f9c 928f123 4572f9c 923e7bc a68da4c 928f123 4572f9c 928f123 4572f9c 923e7bc a68da4c 928f123 4572f9c 928f123 4572f9c 923e7bc a68da4c 928f123 4572f9c 928f123 4572f9c 923e7bc a68da4c 928f123 4572f9c 928f123 4572f9c 923e7bc a68da4c 928f123 4572f9c 928f123 4572f9c 923e7bc a68da4c 928f123 7e4123a 4572f9c 7e4123a e08d6ea 4572f9c 923e7bc a68da4c 4572f9c 7e4123a 4572f9c 7e4123a e08d6ea 4572f9c 923e7bc e08d6ea 4572f9c 7e4123a a95339f 7e4123a e08d6ea a95339f 923e7bc a68da4c a95339f 7e4123a ca3e112 7e4123a e08d6ea ca3e112 923e7bc a68da4c ca3e112 125abbd 928f123 16272b2 125abbd ffff3d1 e08d6ea ffff3d1 7e4123a ffff3d1 7e4123a 923e7bc a68da4c 7e4123a 923e7bc a68da4c 7e4123a 923e7bc a68da4c 7e4123a 923e7bc a68da4c 7e4123a 928f123 e08d6ea 7e4123a 928f123 7a143c1 928f123 7e4123a 928f123 046ea77 928f123 8076230 ae265c6 8076230 e08d6ea 8076230 |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
import gradio as gr
from init import (
get_secrets, initialize_data,
update_dataframe, initialize_repos
)
from gen.openllm import GradioMistralChatPPManager
from gen.gemini_chat import GradioGeminiChatPPManager
from constants.js import (
UPDATE_SEARCH_RESULTS, OPEN_CHAT_IF,
CLOSE_CHAT_IF, UPDATE_CHAT_HISTORY
)
from datetime import datetime, timedelta
from background import process_arxiv_ids
from apscheduler.schedulers.background import BackgroundScheduler
gemini_api_key, hf_token, dataset_repo_id, request_arxiv_repo_id, restart_repo_id = get_secrets()
initialize_repos(dataset_repo_id, request_arxiv_repo_id, hf_token)
titles, date_dict, requested_arxiv_ids_df, arxivid2data = initialize_data(dataset_repo_id, request_arxiv_repo_id)
from ui import (
get_paper_by_year, get_paper_by_month, get_paper_by_day,
set_papers, set_paper, set_date, change_exp_type, add_arxiv_ids_to_queue,
before_chat_begin, chat_stream, chat_reset
)
if len(date_dict.keys()) > 0:
sorted_year = sorted(date_dict.keys())
last_year = sorted_year[-1] if len(sorted_year) > 0 else ""
sorted_month = sorted(date_dict[last_year].keys())
last_month = sorted_month[-1] if len(sorted_year) > 0 else ""
sorted_day = sorted(date_dict[last_year][last_month].keys())
last_day = sorted_day[-1] if len(sorted_year) > 0 else ""
last_papers = date_dict[last_year][last_month][last_day] if len(sorted_year) > 0 else [""]
selected_paper = last_papers[0]
visible = True
else:
sorted_year = ["2024"]
last_year = sorted_year[-1]
sorted_month = ["01"]
last_month = sorted_month[-1]
sorted_day = ["01"]
last_day = sorted_day[-1]
selected_paper = {}
selected_paper["title"] = ""
selected_paper["summary"] = ""
selected_paper["arxiv_id"] = ""
selected_paper["target_date"] = "2024-01-01"
for idx in range(10):
selected_paper[f"{idx}_question"] = ""
selected_paper[f"{idx}_answers:eli5"] = ""
selected_paper[f"{idx}_answers:expert"] = ""
selected_paper[f"{idx}_additional_depth_q:follow up question"] = ""
selected_paper[f"{idx}_additional_depth_q:answers:eli5"] = ""
selected_paper[f"{idx}_additional_depth_q:answers:expert"] = ""
selected_paper[f"{idx}_additional_breath_q:follow up question"] = ""
selected_paper[f"{idx}_additional_breath_q:answers:eli5"] = ""
selected_paper[f"{idx}_additional_breath_q:answers:expert"] = ""
last_papers = [selected_paper]
visible = False
with gr.Blocks(css="constants/styles.css", theme=gr.themes.Soft()) as demo:
cur_arxiv_id = gr.Textbox(selected_paper['arxiv_id'], visible=False)
local_data = gr.JSON({}, visible=False)
chat_state = gr.State({
"ppmanager_type": GradioGeminiChatPPManager # GradioMistralChatPPManager # GradioLLaMA2ChatPPManager
})
with gr.Column(elem_id="chatbot-back"):
with gr.Column(elem_id="chatbot", elem_classes=["hover-opacity"]):
close = gr.Button("π", elem_id="chatbot-right-button") #elem_id="chatbot-right-button")
chatbot = gr.Chatbot(
label="Gemini 1.0 Pro", show_label=True,
show_copy_button=True, show_share_button=True,
visible=True, elem_id="chatbot-inside"
)
with gr.Row(elem_id="chatbot-bottm"):
reset = gr.Button("ποΈ Reset")
regen = gr.Button("π Regenerate", visible=False)
prompt_txtbox = gr.Textbox(placeholder="Ask anything.....", elem_id="chatbot-txtbox", elem_classes=["textbox-no-label"])
gr.Markdown("# Let's explore papers with auto generated Q&As")
with gr.Column(elem_id="control-panel", elem_classes=["group"], visible=visible):
with gr.Column():
with gr.Row():
year_dd = gr.Dropdown(sorted_year, value=last_year, label="Year", interactive=True, filterable=False)
month_dd = gr.Dropdown(sorted_month, value=last_month, label="Month", interactive=True, filterable=False)
day_dd = gr.Dropdown(sorted_day, value=last_day, label="Day", interactive=True, filterable=False)
papers_dd = gr.Dropdown(
list(set([paper["title"] for paper in last_papers])),
value=selected_paper["title"],
label="Select paper title",
interactive=True,
filterable=False
)
with gr.Column(elem_classes=["no-gap"]):
search_in = gr.Textbox("", placeholder="Enter keywords to search...", elem_classes=["textbox-no-label"])
search_r1 = gr.Button(visible=False, elem_id="search_r1", elem_classes=["no-radius"])
search_r2 = gr.Button(visible=False, elem_id="search_r2", elem_classes=["no-radius"])
search_r3 = gr.Button(visible=False, elem_id="search_r3", elem_classes=["no-radius"])
search_r4 = gr.Button(visible=False, elem_id="search_r4", elem_classes=["no-radius"])
search_r5 = gr.Button(visible=False, elem_id="search_r5", elem_classes=["no-radius"])
search_r6 = gr.Button(visible=False, elem_id="search_r6", elem_classes=["no-radius"])
search_r7 = gr.Button(visible=False, elem_id="search_r7", elem_classes=["no-radius"])
search_r8 = gr.Button(visible=False, elem_id="search_r8", elem_classes=["no-radius"])
search_r9 = gr.Button(visible=False, elem_id="search_r9", elem_classes=["no-radius"])
search_r10 = gr.Button(visible=False, elem_id="search_r10", elem_classes=["no-radius"])
with gr.Column(scale=7, visible=visible):
title = gr.Markdown(f"# {selected_paper['title']}", elem_classes=["markdown-center"])
# with gr.Row():
with gr.Row():
arxiv_link = gr.Markdown(
"[![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']) + " "
"[![Paper page](https://huggingface.co/datasets/huggingface/badges/resolve/main/paper-page-lg.svg)](https://huggingface.co/papers/%s)" % selected_paper['arxiv_id'] + " ",
elem_id="link-md",
)
chat_button = gr.Button("Chat about any custom questions", interactive=True, elem_id="chat-button")
summary = gr.Markdown(f"{selected_paper['summary']}", elem_classes=["small-font"])
with gr.Column(elem_id="qna_block", visible=True):
with gr.Row():
with gr.Column(scale=7):
gr.Markdown("## Auto generated Questions & Answers")
exp_type = gr.Radio(choices=["ELI5", "Technical"], value="ELI5", elem_classes=["exp-type"], scale=3)
# 1
with gr.Column(elem_classes=["group"], visible=True) as q_0:
basic_q_0 = gr.Markdown(f"### π {selected_paper['0_question']}")
basic_q_eli5_0 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['0_answers:eli5']}", elem_classes=["small-font"])
basic_q_expert_0 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['0_answers:expert']}", visible=False, elem_classes=["small-font"])
with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_0_0:
depth_q_0 = gr.Markdown(f"### ππ {selected_paper['0_additional_depth_q:follow up question']}")
depth_q_eli5_0 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['0_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
depth_q_expert_0 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['0_additional_depth_q:answers:expert']}", visible=False, elem_classes=["small-font"])
with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_0_1:
breath_q_0 = gr.Markdown(f"### ππ {selected_paper['0_additional_breath_q:follow up question']}")
breath_q_eli5_0 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['0_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
breath_q_expert_0 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['0_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
# 2
with gr.Column(elem_classes=["group"], visible=True) as q_1:
basic_q_1 = gr.Markdown(f"### π {selected_paper['1_question']}")
basic_q_eli5_1 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['1_answers:eli5']}", elem_classes=["small-font"])
basic_q_expert_1 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['1_answers:expert']}", visible=False, elem_classes=["small-font"])
with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_1_0:
depth_q_1 = gr.Markdown(f"### ππ {selected_paper['1_additional_depth_q:follow up question']}")
depth_q_eli5_1 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['1_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
depth_q_expert_1 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['1_additional_depth_q:answers:expert']}", visible=False, elem_classes=["small-font"])
with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_1_1:
breath_q_1 = gr.Markdown(f"### ππ {selected_paper['1_additional_breath_q:follow up question']}")
breath_q_eli5_1 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['1_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
breath_q_expert_1 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['1_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
# 3
with gr.Column(elem_classes=["group"], visible=True) as q_2:
basic_q_2 = gr.Markdown(f"### π {selected_paper['2_question']}")
basic_q_eli5_2 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['2_answers:eli5']}", elem_classes=["small-font"])
basic_q_expert_2 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['2_answers:expert']}", visible=False, elem_classes=["small-font"])
with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_2_0:
depth_q_2 = gr.Markdown(f"### ππ {selected_paper['2_additional_depth_q:follow up question']}")
depth_q_eli5_2 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['2_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
depth_q_expert_2 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['2_additional_depth_q:answers:expert']}", visible=False, elem_classes=["small-font"])
with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_2_1:
breath_q_2 = gr.Markdown(f"### ππ {selected_paper['2_additional_breath_q:follow up question']}")
breath_q_eli5_2 = gr.Markdown(f"βͺ **(ELI5)** {selected_paper['2_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
breath_q_expert_2 = gr.Markdown(f"βͺ **(Technical)** {selected_paper['2_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
gr.Markdown("## Request any arXiv ids")
arxiv_queue = gr.Dataframe(
headers=["Requested arXiv IDs"], col_count=(1, "fixed"),
value=requested_arxiv_ids_df,
datatype=["str"],
interactive=False,
)
arxiv_id_enter = gr.Textbox(placeholder="Enter comma separated arXiv IDs...", elem_classes=["textbox-no-label"])
arxiv_id_enter.submit(
add_arxiv_ids_to_queue,
[arxiv_queue, arxiv_id_enter],
[arxiv_queue, arxiv_id_enter],
concurrency_limit=20,
)
gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
gr.Markdown("The target papers are collected from [Hugging Face π€ Daily Papers](https://huggingface.co/papers) on a daily basis. "
"The entire data is generated by [Google's Gemini 1.0](https://deepmind.google/technologies/gemini/) Pro. "
"If you are curious how it is done, visit the [Auto Paper Q&A Generation project repository](https://github.com/deep-diver/auto-paper-analysis) "
"Also, the generated dataset is hosted on Hugging Face π€ Dataset repository as well([Link](https://huggingface.co/datasets/chansung/auto-paper-qa2)). ")
search_r1.click(set_date, search_r1, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r1],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r2.click(set_date, search_r2, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r2],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r3.click(set_date, search_r3, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r3],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r4.click(set_date, search_r4, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r4],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r5.click(set_date, search_r5, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r5],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r6.click(set_date, search_r6, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r6],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r7.click(set_date, search_r7, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r7],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r8.click(set_date, search_r8, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r8],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r9.click(set_date, search_r9, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r9],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
search_r10.click(set_date, search_r10, [year_dd, month_dd, day_dd]).then(
set_papers,
inputs=[year_dd, month_dd, day_dd, search_r10],
outputs=[cur_arxiv_id, papers_dd, search_in],
concurrency_limit=20,
)
year_dd.input(get_paper_by_year, inputs=[year_dd], outputs=[month_dd, day_dd, papers_dd]).then(
set_paper, [year_dd, month_dd, day_dd, papers_dd],
[
cur_arxiv_id,
title, arxiv_link, summary,
basic_q_0, basic_q_eli5_0, basic_q_expert_0,
depth_q_0, depth_q_eli5_0, depth_q_expert_0,
breath_q_0, breath_q_eli5_0, breath_q_expert_0,
basic_q_1, basic_q_eli5_1, basic_q_expert_1,
depth_q_1, depth_q_eli5_1, depth_q_expert_1,
breath_q_1, breath_q_eli5_1, breath_q_expert_1,
basic_q_2, basic_q_eli5_2, basic_q_expert_2,
depth_q_2, depth_q_eli5_2, depth_q_expert_2,
breath_q_2, breath_q_eli5_2, breath_q_expert_2
],
concurrency_limit=20,
)
month_dd.input(get_paper_by_month, inputs=[year_dd, month_dd], outputs=[day_dd, papers_dd]).then(
set_paper, [year_dd, month_dd, day_dd, papers_dd],
[
cur_arxiv_id,
title, arxiv_link, summary,
basic_q_0, basic_q_eli5_0, basic_q_expert_0,
depth_q_0, depth_q_eli5_0, depth_q_expert_0,
breath_q_0, breath_q_eli5_0, breath_q_expert_0,
basic_q_1, basic_q_eli5_1, basic_q_expert_1,
depth_q_1, depth_q_eli5_1, depth_q_expert_1,
breath_q_1, breath_q_eli5_1, breath_q_expert_1,
basic_q_2, basic_q_eli5_2, basic_q_expert_2,
depth_q_2, depth_q_eli5_2, depth_q_expert_2,
breath_q_2, breath_q_eli5_2, breath_q_expert_2
],
concurrency_limit=20,
)
day_dd.input(get_paper_by_day, inputs=[year_dd, month_dd, day_dd], outputs=[papers_dd]).then(
set_paper, [year_dd, month_dd, day_dd, papers_dd],
[
cur_arxiv_id,
title, arxiv_link, summary,
basic_q_0, basic_q_eli5_0, basic_q_expert_0,
depth_q_0, depth_q_eli5_0, depth_q_expert_0,
breath_q_0, breath_q_eli5_0, breath_q_expert_0,
basic_q_1, basic_q_eli5_1, basic_q_expert_1,
depth_q_1, depth_q_eli5_1, depth_q_expert_1,
breath_q_1, breath_q_eli5_1, breath_q_expert_1,
basic_q_2, basic_q_eli5_2, basic_q_expert_2,
depth_q_2, depth_q_eli5_2, depth_q_expert_2,
breath_q_2, breath_q_eli5_2, breath_q_expert_2
],
concurrency_limit=20,
)
papers_dd.change(set_paper, [year_dd, month_dd, day_dd, papers_dd],
[
cur_arxiv_id,
title, arxiv_link, summary,
basic_q_0, basic_q_eli5_0, basic_q_expert_0,
depth_q_0, depth_q_eli5_0, depth_q_expert_0,
breath_q_0, breath_q_eli5_0, breath_q_expert_0,
basic_q_1, basic_q_eli5_1, basic_q_expert_1,
depth_q_1, depth_q_eli5_1, depth_q_expert_1,
breath_q_1, breath_q_eli5_1, breath_q_expert_1,
basic_q_2, basic_q_eli5_2, basic_q_expert_2,
depth_q_2, depth_q_eli5_2, depth_q_expert_2,
breath_q_2, breath_q_eli5_2, breath_q_expert_2
],
concurrency_limit=20,
)
search_in.change(
inputs=[search_in],
outputs=[
search_r1, search_r2, search_r3, search_r4, search_r5,
search_r6, search_r7, search_r8, search_r9, search_r10
],
js=UPDATE_SEARCH_RESULTS % str(list(titles)),
fn=None
)
exp_type.select(
change_exp_type,
exp_type,
[
basic_q_eli5_0, basic_q_expert_0, depth_q_eli5_0, depth_q_expert_0, breath_q_eli5_0, breath_q_expert_0,
basic_q_eli5_1, basic_q_expert_1, depth_q_eli5_1, depth_q_expert_1, breath_q_eli5_1, breath_q_expert_1,
basic_q_eli5_2, basic_q_expert_2, depth_q_eli5_2, depth_q_expert_2, breath_q_eli5_2, breath_q_expert_2
],
concurrency_limit=20,
)
chat_button.click(None, [cur_arxiv_id], [local_data, chatbot], js=OPEN_CHAT_IF)
close.click(None, None, None,js=CLOSE_CHAT_IF)
prompt_txtbox.submit(
before_chat_begin, None, [close, reset, regen],
concurrency_limit=20,
).then(
chat_stream,
[cur_arxiv_id, local_data, prompt_txtbox, chat_state],
[prompt_txtbox, chatbot, local_data, close, reset, regen],
concurrency_limit=20,
).then(
None, [cur_arxiv_id, local_data], None,
js=UPDATE_CHAT_HISTORY
)
reset.click(
before_chat_begin, None, [close, reset, regen],
concurrency_limit=20,
).then(
chat_reset,
[local_data, chat_state],
[prompt_txtbox, chatbot, local_data, close, reset, regen],
concurrency_limit=20,
).then(
None, [cur_arxiv_id, local_data], None,
js=UPDATE_CHAT_HISTORY
)
demo.load(lambda: update_dataframe(request_arxiv_repo_id), None, arxiv_queue, every=180)
# demo.load(None, None, [chatbot, local_data], js=GET_LOCAL_STORAGE % idx.value)
start_date = datetime.now() + timedelta(minutes=1)
scheduler = BackgroundScheduler()
scheduler.add_job(
process_arxiv_ids,
trigger='interval',
seconds=300,
args=[
gemini_api_key,
dataset_repo_id,
request_arxiv_repo_id,
hf_token,
restart_repo_id
],
start_date=start_date
)
scheduler.start()
demo.queue(
default_concurrency_limit=20,
max_size=256
).launch(
share=True, debug=True
) |