Blessin commited on
Commit
9f1c590
·
1 Parent(s): 8f7ea33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -5,15 +5,14 @@ import random
5
  from io import StringIO
6
  from datasets import load_dataset
7
 
8
- # Fetch dialogues from the provided URL
9
- response = requests.get("https://huggingface.co/datasets/Blessin/dialogues-one-liners/blob/main/dialogues_dataset.json")
10
- response.raise_for_status() # Ensure the request was successful
11
- data = response.json()
12
- DIALOGUES = data["dialogues"]
13
 
14
  def generate_statement():
15
- # Fetch a random dialogue from the loaded dataset
16
- return random.choice(DIALOGUES)
 
17
 
18
  def main():
19
  # Define the UI components using gr.Interface
@@ -29,4 +28,4 @@ def main():
29
  interface.launch(share=True)
30
 
31
  if __name__ == "__main__":
32
- main()
 
5
  from io import StringIO
6
  from datasets import load_dataset
7
 
8
+ # Load the dataset from Hugging Face Spaces
9
+ dataset = load_dataset("Blessin/dialogues-one-liners")
10
+ DIALOGUES = dataset["train"]["dialogue"]
 
 
11
 
12
  def generate_statement():
13
+ # Generate a random statement from the dataset
14
+ index = random.randint(0, len(DIALOGUES) - 1)
15
+ return DIALOGUES[index]
16
 
17
  def main():
18
  # Define the UI components using gr.Interface
 
28
  interface.launch(share=True)
29
 
30
  if __name__ == "__main__":
31
+ main()