File size: 724 Bytes
6ab7e47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53041a7
6ab7e47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#import model class and tokenizer
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration

#import model class and tokenizer
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration

#download and setup the model and tokenizer
model_name = 'facebook/blenderbot-400M-distill'
tokenizer = BlenderbotTokenizer.from_pretrained(model_name)
model = BlenderbotForConditionalGeneration.from_pretrained(model_name)

def func (message):
  inputs = tokenizer(message, return_tensors="pt")
  result = model.generate(**inputs)
  return tokenizer.decode(result[0])

import gradio as gr
app = gr.Interface(fn=func, inputs="textbox", outputs="textbox", title="Conversation Bot")
app.launch()