not-lain commited on
Commit
3d8c9c6
ยท
1 Parent(s): 983f3b4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a pipeline as a high-level helper
2
+ from transformers import pipeline, Conversation
3
+ 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
+
19
+ gr.ChatInterface(predict).queue().launch()