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

Test with getting first sentence

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,9 +1,12 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- def greet(name):
5
- generator = pipeline("text-generation")
6
- return generator(name)
 
 
 
7
 
8
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
  iface.launch()
 
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()