bakilasek commited on
Commit
b271f4b
·
verified ·
1 Parent(s): c22122c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
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
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
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()