Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
pipe = pipeline("text-generation", model="openai-community/gpt2")
|
| 5 |
+
|
| 6 |
+
def chat(text):
|
| 7 |
+
result= pipe.generate(text)
|
| 8 |
+
return result
|
| 9 |
+
|
| 10 |
+
with gr.blocks(title='Basic chatbot based on gpt2') as demo:
|
| 11 |
+
with gr.Row():
|
| 12 |
+
user_input = gr.Textbox(placeholder="Type your message here...", label="Your Message", lines=2)
|
| 13 |
+
|
| 14 |
+
with gr.Row():
|
| 15 |
+
output = gr.Textbox(label="Response", lines=4)
|
| 16 |
+
|
| 17 |
+
with gr.Row():
|
| 18 |
+
submit_btn = gr.Button("Send")
|
| 19 |
+
|
| 20 |
+
submit_btn.click(fn=chat, inputs=input, outputs=output)
|
| 21 |
+
|
| 22 |
+
demo.launch()
|