Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,13 @@ from transformers import Conversation
|
|
| 5 |
chatbot = pipeline(task="conversational", model="facebook/blenderbot-400M-distill")
|
| 6 |
conversation = Conversation()
|
| 7 |
|
| 8 |
-
def greet(name):
|
| 9 |
global conversation
|
|
|
|
|
|
|
| 10 |
conversation.add_message({"role": "user",
|
| 11 |
"content": name})
|
| 12 |
conversation = chatbot(conversation)
|
| 13 |
return conversation.messages[len(conversation.messages) -1]
|
| 14 |
|
| 15 |
-
|
| 16 |
-
iface.launch(share=True)
|
|
|
|
| 5 |
chatbot = pipeline(task="conversational", model="facebook/blenderbot-400M-distill")
|
| 6 |
conversation = Conversation()
|
| 7 |
|
| 8 |
+
def greet(name, history):
|
| 9 |
global conversation
|
| 10 |
+
if len(history) == 0:
|
| 11 |
+
conversation = Conversation()
|
| 12 |
conversation.add_message({"role": "user",
|
| 13 |
"content": name})
|
| 14 |
conversation = chatbot(conversation)
|
| 15 |
return conversation.messages[len(conversation.messages) -1]
|
| 16 |
|
| 17 |
+
gr.ChatInterface(greet).launch()
|
|
|