File size: 1,042 Bytes
506cc7d
5f64618
8255a04
5f64618
995e58e
9f1c590
384cca9
995e58e
 
55f0ffd
7a57a32
995e58e
7e7761c
 
 
 
 
506cc7d
c8e6137
995e58e
c8e6137
995e58e
 
 
 
fb10634
506cc7d
c8e6137
995e58e
c8e6137
506cc7d
 
fb10634
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
import gradio as gr
import random
from datasets import load_dataset

# Load the dataset from Hugging Face
dataset = load_dataset("Blessin/dialogues-one-liners")

# Extract the dialogues from the dataset
DIALOGUES = dataset["train"]["dialogues"]

def generate_statement():
    """Return a random dialogue from the dataset."""
    # Pick a random sublist from the dataset
    random_dialogue_list = random.choice(DIALOGUES)
    # Pick a random dialogue from the sublist
    return random.choice(random_dialogue_list)


def main():
    # Define the UI using gr.Interface
    interface = gr.Interface(
        fn=generate_statement,  # Function to call on button press
        inputs=[],              # No inputs required
        outputs="text",         # Output is a text area
        live=False,             # Only generate statement after button press
        description="Press the button to generate a random statement from the dataset."
    )
    
    # Launch the UI
    interface.launch(share=True)

if __name__ == "__main__":
    main()