File size: 472 Bytes
1d84c12
 
 
 
 
 
 
 
 
 
 
 
 
590e00a
1d84c12
590e00a
1d84c12
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

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()