not-lain commited on
Commit
41f08a6
ยท
1 Parent(s): 7b6ce24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -4,15 +4,13 @@ import gradio as gr
4
 
5
 
6
  chatbot = pipeline("conversational", model="ericzhou/DialoGPT-Medium-Rick_v2")
7
- conversation = None # initialization
8
  def predict(sentence,history) :
9
- global conversation
10
- if not conversation :
11
- # initial generation
12
- conversation = Conversation(sentence)
13
- else :
14
- # mid conversation
15
- conversation.add_user_input(sentence)
16
  conversation = chatbot(conversation)
17
  return conversation.generated_responses[-1]
18
 
 
4
 
5
 
6
  chatbot = pipeline("conversational", model="ericzhou/DialoGPT-Medium-Rick_v2")
7
+
8
  def predict(sentence,history) :
9
+ conversation = Conversation()
10
+ for hist in history:
11
+ conversation.add_user_input(hist[0])
12
+ conversation.append_response(hist[1])
13
+ conversation.add_user_input(sentence)
 
 
14
  conversation = chatbot(conversation)
15
  return conversation.generated_responses[-1]
16