File size: 588 Bytes
7b08850 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
import torch
from transformers import pipeline
generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
def get_msg(prompt):
res = generator(prompt, max_length=50, do_sample=True, temperature=0.9)
message = res[0]['generated_text']
return message.strip()
def chatbot(input, history=[]):
output = get_msg(input)
history.append((input, output))
return history, history
gr.Interface(fn = chatbot,
inputs = ["text",'state'],
outputs = ["chatbot",'state']).queue(concurrency_count=1,max_size=1).launch() |