Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,28 @@
|
|
| 1 |
-
import openai
|
| 2 |
import gradio as gr
|
| 3 |
-
import requests
|
| 4 |
import random
|
| 5 |
-
from io import StringIO
|
| 6 |
from datasets import load_dataset
|
| 7 |
|
| 8 |
-
# Load the dataset from Hugging Face
|
| 9 |
dataset = load_dataset("Blessin/dialogues-one-liners")
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# Access the dialogue data
|
| 15 |
-
DIALOGUES = dataset["train"][column_name]
|
| 16 |
|
| 17 |
def generate_statement():
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
return DIALOGUES[index]
|
| 21 |
|
| 22 |
def main():
|
| 23 |
-
# Define the UI
|
| 24 |
interface = gr.Interface(
|
| 25 |
-
fn=generate_statement,
|
| 26 |
-
inputs=[],
|
| 27 |
-
outputs="text",
|
| 28 |
-
live=
|
| 29 |
-
description="Press the button to generate a statement from
|
| 30 |
)
|
| 31 |
|
| 32 |
-
# Launch the UI
|
| 33 |
interface.launch(share=True)
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import random
|
|
|
|
| 3 |
from datasets import load_dataset
|
| 4 |
|
| 5 |
+
# Load the dataset from Hugging Face
|
| 6 |
dataset = load_dataset("Blessin/dialogues-one-liners")
|
| 7 |
|
| 8 |
+
# Extract the dialogues from the dataset
|
| 9 |
+
DIALOGUES = dataset["train"]["dialogues"]
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def generate_statement():
|
| 12 |
+
"""Return a random dialogue from the dataset."""
|
| 13 |
+
return random.choice(DIALOGUES)
|
|
|
|
| 14 |
|
| 15 |
def main():
|
| 16 |
+
# Define the UI using gr.Interface
|
| 17 |
interface = gr.Interface(
|
| 18 |
+
fn=generate_statement, # Function to call on button press
|
| 19 |
+
inputs=[], # No inputs required
|
| 20 |
+
outputs="text", # Output is a text area
|
| 21 |
+
live=False, # Only generate statement after button press
|
| 22 |
+
description="Press the button to generate a statement from the dataset."
|
| 23 |
)
|
| 24 |
|
| 25 |
+
# Launch the UI
|
| 26 |
interface.launch(share=True)
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|