DutchNomadCode commited on
Commit
5c7fdb7
1 Parent(s): 62c4079

Change to full sentence

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,12 +1,13 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- def greet(input):
5
  generator = pipeline("text-generation", model="distilgpt2")
6
  generated_text = generator(input)[0]['generated_text']
7
- # Extract the first sentence and format it
8
- first_sentence = generated_text.split('.')[0].strip()
9
- return f"'{first_sentence}'"
 
10
 
11
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
12
- iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ def text_gen(input):
5
  generator = pipeline("text-generation", model="distilgpt2")
6
  generated_text = generator(input)[0]['generated_text']
7
+ # Split the generated text into sentences and concatenate them
8
+ sentences = generated_text.split('.')
9
+ full_sentence = ' '.join(sentence.strip() for sentence in sentences if sentence.strip())
10
+ return f"'{full_sentence}'"
11
 
12
+ iface = gr.Interface(fn=text_gen, inputs="text", outputs="text")
13
+ iface.launch()