Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,24 +4,34 @@ from transformers import pipeline
|
|
| 4 |
# Initialize a text generation pipeline
|
| 5 |
generator = pipeline('text-generation', model='dbmdz/german-gpt2')
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
st.
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
def generate_content(topic):
|
| 18 |
-
generated_text = generator(f"Letzte Nachrichten über {topic}:", max_length=50, num_return_sequences=1)
|
| 19 |
-
return generated_text[0]['generated_text']
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
st.success('Generated Content:')
|
| 25 |
-
st.write(post_content)
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
# Initialize a text generation pipeline
|
| 5 |
generator = pipeline('text-generation', model='dbmdz/german-gpt2')
|
| 6 |
|
| 7 |
+
# Define the pages
|
| 8 |
+
def page_social_media_generator():
|
| 9 |
+
st.title('German Medical Content Manager')
|
| 10 |
+
input_topic = st.text_input('Enter a medical topic', 'Type 1 Diabetes')
|
| 11 |
+
st.write(f"Creating social media content for: {input_topic}")
|
| 12 |
|
| 13 |
+
def generate_content(topic):
|
| 14 |
+
generated_text = generator(f"Letzte Nachrichten über {topic}:", max_length=50, num_return_sequences=1)
|
| 15 |
+
return generated_text[0]['generated_text']
|
| 16 |
|
| 17 |
+
if st.button('Generate Social Media Post'):
|
| 18 |
+
with st.spinner('Generating...'):
|
| 19 |
+
post_content = generate_content(input_topic)
|
| 20 |
+
st.success('Generated Content:')
|
| 21 |
+
st.write(post_content)
|
| 22 |
|
| 23 |
+
st.write('Generated social media posts will appear here after clicking the "Generate" button.')
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
def page_test():
|
| 26 |
+
st.title('Test Page')
|
| 27 |
+
st.write('This is a test page with a test name.')
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# Setup the sidebar with page selection
|
| 30 |
+
st.sidebar.title("Anne's Current Projects")
|
| 31 |
+
page = st.sidebar.radio('Select a Page:', ['Social Media Content Generator', 'Test Page'])
|
| 32 |
+
|
| 33 |
+
# Display the selected page
|
| 34 |
+
if page == 'Social Media Content Generator':
|
| 35 |
+
page_social_media_generator()
|
| 36 |
+
elif page == 'Test Page':
|
| 37 |
+
page_test()
|