File size: 397 Bytes
a98fecc 3ad1bbb dae99b3 a98fecc 0b35cbd dae99b3 a98fecc 0d8fbad a98fecc d355ac9 dae99b3 a98fecc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from transformers import pipeline
import textwrap
import time
import gradio as gr
# Load a pre-trained chatbot model
chatbot = pipeline('text-generation', model='gpt2-large')
def wrap(x):
return textwrap.fill(x, replace_whitespace=False, fix_sentence_endings=True)
def chat(prompt):
return chatbot(prompt)[0]['generated_text']
gr.Interface(fn=chat, inputs="text", outputs="text").launch()
|