Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
chatbot = pipeline("text2text-generation", model="google/flan-t5-small")
|
| 5 |
+
|
| 6 |
+
def respond(message, history):
|
| 7 |
+
if not message:
|
| 8 |
+
return "Ask me something 😊"
|
| 9 |
+
|
| 10 |
+
prompt = "Answer clearly and simply like a helpful tutor: " + message
|
| 11 |
+
response = chatbot(prompt, max_length=100)
|
| 12 |
+
|
| 13 |
+
return response[0]['generated_text']
|
| 14 |
+
|
| 15 |
+
demo = gr.ChatInterface(fn=respond)
|
| 16 |
+
|
| 17 |
+
demo.launch()
|