simple_chatbot / app.py
bakilasek's picture
Update app.py
ca243e2 verified
raw
history blame contribute delete
562 Bytes
import gradio as gr
from transformers import pipeline
from transformers import Conversation
chatbot = pipeline(task="conversational", model="facebook/blenderbot-400M-distill")
conversation = Conversation()
def greet(name, history):
global conversation
if len(history) == 0:
conversation = Conversation()
conversation.add_message({"role": "user",
"content": name})
conversation = chatbot(conversation)
return conversation.messages[len(conversation.messages) -1]['content']
gr.ChatInterface(greet).launch()