File size: 2,086 Bytes
ad10fb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from huggingface_hub import HfApi
from datasets import load_dataset, Dataset
import os
import uuid
import json

# Set your HF credentials
HF_TOKEN = os.getenv("HF_TOKEN")  # In Space, add as a secret variable
DATASET_REPO = "your-username/submitted-papers"  # Replace with your dataset repo

# Load dataset (or create dummy if doesn't exist)
def append_to_dataset(entry):
    try:
        # Load current dataset
        dataset = load_dataset(DATASET_REPO, split="train", token=HF_TOKEN)
        data = dataset.to_list()
    except Exception:
        data = []

    # Append new entry
    data.append(entry)

    # Save locally and push
    new_dataset = Dataset.from_list(data)
    new_dataset.push_to_hub(DATASET_REPO, token=HF_TOKEN)

def submit_paper(title, authors, abstract, category, paper_url, originality):
    if not originality:
        return "You must confirm that this is your own submission."

    entry = {
        "id": str(uuid.uuid4()),
        "title": title,
        "authors": authors,
        "abstract": abstract,
        "category": category,
        "url": paper_url
    }

    append_to_dataset(entry)
    return "βœ… Submission successful!"

# Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("## πŸ“„ Submit Your Paper")

    with gr.Row():
        title = gr.Textbox(label="Title", placeholder="Enter paper title")
        authors = gr.Textbox(label="Authors", placeholder="Jane Doe, John Smith")

    abstract = gr.Textbox(label="Abstract", lines=6)
    category = gr.Dropdown(
        label="Category",
        choices=["NLP", "CV", "Audio", "Theory", "Robotics", "Other"],
        value="NLP"
    )
    paper_url = gr.Textbox(label="Paper URL (arXiv or PDF)", placeholder="https://...")

    originality = gr.Checkbox(label="I confirm this is my own work")

    submit_btn = gr.Button("Submit")
    output = gr.Textbox(label="Status", interactive=False)

    submit_btn.click(
        fn=submit_paper,
        inputs=[title, authors, abstract, category, paper_url, originality],
        outputs=output
    )

demo.launch()