File size: 530 Bytes
a653fea
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import gradio as gr

from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration

tokenizer = BlenderbotTokenizer.from_pretrained('facebook/blenderbot-1B-distill')
model = BlenderbotForConditionalGeneration.from_pretrained('facebook/blenderbot-1B-distill')

def func (message):
  inputs = tokenizer(message, return_tensors='pt')
  result = model.generate(**inputs)
  return tokenizer.decode(result[0])
  
app = gr.Interface(fn=func, inputs = 'textbox', outputs = 'textbox', title='Chatbot Three')
app.launch()