File size: 774 Bytes
3d8c9c6
 
 
 
 
 
41f08a6
3d8c9c6
41f08a6
 
 
 
 
3d8c9c6
 
 
7b6ce24
 
 
 
 
 
 
 
dbe0dc7
7b6ce24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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")

def predict(sentence,history) : 
  conversation = Conversation()
  for hist in history: 
    conversation.add_user_input(hist[0])
    conversation.append_response(hist[1])
  conversation.add_user_input(sentence)
  conversation = chatbot(conversation)
  return conversation.generated_responses[-1]

header = """
<center>
<h1> chat with rick and morty </h1>
<img src="https://huggingface.co/spaces/not-lain/DialoGPT-Medium-Rick_v2/resolve/main/rick.png">
</center>
"""
with gr.Blocks() as iface : 
  gr.Markdown(header)
  gr.ChatInterface(predict,autofocus=False)
iface.queue().launch()