HFUsman commited on
Commit
247a4a5
·
verified ·
1 Parent(s): 8cadacf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -9
app.py CHANGED
@@ -112,8 +112,10 @@ if uploaded_files or manual_input:
112
 
113
  if task == "Generate Presentation (PPT)":
114
  topic = st.text_input("Enter the topic for the presentation:")
115
- if st.button("Generate Presentation"):
116
- presentation_content = []
 
 
117
  for chunk in text_chunks:
118
  content = process_with_groq([{
119
  "role": "system", "content": "Generate content for a presentation slide."
@@ -123,13 +125,48 @@ if uploaded_files or manual_input:
123
 
124
  slides = content.split("\n")
125
  title = slides[0] # First line as the slide title
126
- slide_content = slides[1:] # Remaining lines as bullet points
127
- presentation_content.append((title, slide_content))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
- ppt_file = save_to_ppt(presentation_content)
130
- st.write("### Generated Presentation")
131
- st.download_button("Download Presentation (PPT)", ppt_file, file_name="presentation.pptx")
132
-
133
- # Other tasks like "Summarize a Topic", "Ask Questions", etc. remain unchanged
134
  else:
135
  st.info("Please upload files or enter lesson text to get started.")
 
112
 
113
  if task == "Generate Presentation (PPT)":
114
  topic = st.text_input("Enter the topic for the presentation:")
115
+
116
+ if topic:
117
+ # Generate slide content based on the topic
118
+ slide_content = []
119
  for chunk in text_chunks:
120
  content = process_with_groq([{
121
  "role": "system", "content": "Generate content for a presentation slide."
 
125
 
126
  slides = content.split("\n")
127
  title = slides[0] # First line as the slide title
128
+ slide_content_points = slides[1:] # Remaining lines as bullet points
129
+ slide_content.append((title, slide_content_points))
130
+
131
+ # Show the generated slide content for review
132
+ st.subheader("Generated Presentation Content")
133
+ for i, (slide_title, slide_content_points) in enumerate(slide_content):
134
+ st.write(f"### {slide_title}")
135
+ for point in slide_content_points:
136
+ st.write(f"- {point}")
137
+ st.markdown("---")
138
+
139
+ # Option to regenerate the content
140
+ regenerate = st.button("Regenerate Content")
141
+ if regenerate:
142
+ st.write("Content regenerated. Review again!")
143
+ # Regenerate the content by calling the same process again
144
+ slide_content = []
145
+ for chunk in text_chunks:
146
+ content = process_with_groq([{
147
+ "role": "system", "content": "Generate content for a presentation slide."
148
+ }, {
149
+ "role": "user", "content": f"Topic: {topic}\n\nProvide a few bullet points for a slide on the following content: {chunk}"
150
+ }])
151
+
152
+ slides = content.split("\n")
153
+ title = slides[0] # First line as the slide title
154
+ slide_content_points = slides[1:] # Remaining lines as bullet points
155
+ slide_content.append((title, slide_content_points))
156
+
157
+ # Show regenerated content
158
+ st.subheader("Regenerated Presentation Content")
159
+ for i, (slide_title, slide_content_points) in enumerate(slide_content):
160
+ st.write(f"### {slide_title}")
161
+ for point in slide_content_points:
162
+ st.write(f"- {point}")
163
+ st.markdown("---")
164
+
165
+ # Allow download once the user is satisfied
166
+ if st.button("Generate PowerPoint"):
167
+ ppt_file = save_to_ppt(slide_content)
168
+ st.write("### Generated Presentation")
169
+ st.download_button("Download Presentation (PPT)", ppt_file, file_name="presentation.pptx")
170
 
 
 
 
 
 
171
  else:
172
  st.info("Please upload files or enter lesson text to get started.")