File size: 797 Bytes
6db9c1d
 
 
 
73e7fb7
6db9c1d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
from transformers import pipeline

# Load the pre-trained language model
generator = pipeline("text-generation", model="gpt2")

# Streamlit app
st.title("Blog Post Generator")
st.write("Generate a blog post for a given topic using GPT-2.")

# Input for the blog post topic
topic = st.text_input("Enter a blog post topic:")

if st.button("Generate"):
    if topic:
        # Generate a blog post based on the given topic
        with st.spinner("Generating blog post..."):
            result = generator(f"Blog post topic: {topic}\n\nBlog post content:", max_length=500)
            blog_post = result[0]['generated_text']
        st.subheader("Generated Blog Post")
        st.write(blog_post)
    else:
        st.warning("Please enter a topic to generate the blog post.")