not-lain's picture
Create app.py
3d8c9c6
raw
history blame
576 Bytes
# Use a pipeline as a high-level helper
from transformers import pipeline, Conversation
import gradio as gr
chatbot = pipeline("conversational", model="ericzhou/DialoGPT-Medium-Rick_v2")
conversation = None # initialization
def predict(sentence,history) :
global conversation
if not conversation :
# initial generation
conversation = Conversation(sentence)
else :
# mid conversation
conversation.add_user_input(sentence)
conversation = chatbot(conversation)
return conversation.generated_responses[-1]
gr.ChatInterface(predict).queue().launch()