Spaces:
Runtime error
Runtime error
| 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() |