Spaces:
Running
Running
import streamlit as st | |
from transformers import pipeline | |
# Initialize a text generation pipeline | |
generator = pipeline('text-generation', model='dbmdz/german-gpt2') | |
st.title('German Medical Content Manager') | |
# Sidebar for user input | |
st.sidebar.header('User Input Options') | |
input_topic = st.sidebar.text_input('Enter a medical topic', 'Type 1 Diabetes') | |
# Main Page | |
st.write(f"Creating social media content for: {input_topic}") | |
# Function to generate text based on the input topic | |
def generate_content(topic): | |
generated_text = generator(f"Letzte Nachrichten über {topic}:", max_length=50, num_return_sequences=1) | |
return generated_text[0]['generated_text'] | |
if st.button('Generate Social Media Post'): | |
with st.spinner('Generating...'): | |
post_content = generate_content(input_topic) | |
st.success('Generated Content:') | |
st.write(post_content) | |
st.write('Generated social media posts will appear here after clicking the "Generate" button.') | |