import gradio as gr from transformers import pipeline pipe = pipeline("text-generation", model="ismaelfaro/gpt2-poems.en") def poetchat(message, history): text_generated = pipe(message)[0]['generated_text'] text_generated_cleaned = "\n".join(text_generated.replace("\\\\n","\\n").split('\\n')) return text_generated_cleaned title = "chat with a AIpoet" demo = gr.ChatInterface(poetchat, title=title, theme = 'Taithrah/Minimal') demo.queue().launch()