Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline, Conversation
|
| 2 |
+
import gradio as gr
|
| 3 |
+
chatbot = pipeline(model="facebook/blenderbot-400M-distill")
|
| 4 |
+
message_list = []
|
| 5 |
+
response_list = []
|
| 6 |
+
def vanilla_chatbot(message, history):
|
| 7 |
+
conversation = Conversation(text=message, past_user_inputs=message_list,
|
| 8 |
+
generated_responses=response_list)
|
| 9 |
+
bot = chatbot(conversation.messages[0]['content']) # working code
|
| 10 |
+
return bot[-1]['generated_text']
|
| 11 |
+
|
| 12 |
+
demo_chatbot = gr.ChatInterface(vanilla_chatbot, title="Mashdemy Chatbot", description="Enter text to start
|
| 13 |
+
chatting.")
|
| 14 |
+
demo_chatbot.launch(share = True)
|