Anne314159 commited on
Commit
e6c03c9
·
verified ·
1 Parent(s): de18d13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -16
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
- st.title('German Medical Content Manager')
 
 
 
 
8
 
9
- # Sidebar for user input
10
- st.sidebar.header('User Input Options')
11
- input_topic = st.sidebar.text_input('Enter a medical topic', 'Type 1 Diabetes')
12
 
13
- # Main Page
14
- st.write(f"Creating social media content for: {input_topic}")
 
 
 
15
 
16
- # Function to generate text based on the input topic
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
- if st.button('Generate Social Media Post'):
22
- with st.spinner('Generating...'):
23
- post_content = generate_content(input_topic)
24
- st.success('Generated Content:')
25
- st.write(post_content)
26
 
27
- st.write('Generated social media posts will appear here after clicking the "Generate" button.')
 
 
 
 
 
 
 
 
 
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()