File size: 1,026 Bytes
fb18c58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pandas as pd
import gradio as gr
from huggingface_hub import hf_hub_download
import os

guest_list = hf_hub_download("freddyaboulton/names", "guests.csv", repo_type="dataset",
                             token=os.environ["TOKEN"])


GUESTS = set(pd.read_csv(guest_list).Name.str.lower())

def checkin(s: str):
    s = s.lower()
    color = "green" if s in GUESTS else "red"
    value = "on list" if s in GUESTS else "not on list"
    return gr.Label.update(value=value, color=color)

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            name = gr.Textbox(label="Name", info="Name on Partiful. Case insensitive. Hit enter or button")
            checkin_btn = gr.Button(value="Check in")
            # add = gr.Button(value="Add name to list")
        with gr.Column():
            result = gr.Label(label="Are they on the list?")
    name.submit(checkin, name, result)
    checkin_btn.click(checkin, name, result)
    # add.click(add_to_list, name, None)

demo.launch(enable_queue=False)