banao-tech commited on
Commit
febc5c7
Β·
verified Β·
1 Parent(s): 549f6a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +289 -167
app.py CHANGED
@@ -3,9 +3,15 @@ import json
3
  from datetime import datetime
4
  import time
5
  import requests
 
 
6
 
7
- # API endpoint (replace with your actual endpoint)
8
- API_ENDPOINT = "https://api.example.com/personalize-course"
 
 
 
 
9
 
10
  # Set page configuration
11
  st.set_page_config(
@@ -46,6 +52,7 @@ st.markdown("""
46
  font-weight: 600;
47
  color: var(--header-color);
48
  margin-bottom: 1rem;
 
49
  }
50
 
51
  .section-header {
@@ -82,17 +89,8 @@ st.markdown("""
82
  border-color: var(--border-color);
83
  }
84
 
85
- .stTextInput > div > div > input {
86
- background-color: var(--background-color);
87
- color: var(--text-color);
88
- border-color: var(--border-color);
89
- }
90
-
91
- .stNumberInput > div > div > input {
92
- background-color: var(--background-color);
93
- color: var(--text-color);
94
- }
95
-
96
  .stTextArea > div > div > textarea {
97
  background-color: var(--background-color);
98
  color: var(--text-color);
@@ -115,11 +113,6 @@ st.markdown("""
115
  border-color: var(--border-color);
116
  }
117
 
118
- /* Footer */
119
- footer {
120
- color: #888888;
121
- }
122
-
123
  /* API Response Container */
124
  .api-response {
125
  background-color: #1A1A1A;
@@ -128,53 +121,139 @@ st.markdown("""
128
  border-left: 4px solid var(--accent-color);
129
  }
130
 
131
- /* Custom label colors for Full Name and Gender */
132
- [data-testid="stForm"] label:contains("Full Name"),
133
- [data-testid="stForm"] label:contains("Gender") {
134
- color: white !important;
135
- font-weight: 500;
136
- }
137
-
138
- /* Alternative approach if the above doesn't work */
139
- .st-emotion-cache-1gulkj5 label, /* For Full Name */
140
- .st-emotion-cache-1aumxhf label { /* For Gender */
141
- color: white !important;
142
  }
143
  </style>
144
  """, unsafe_allow_html=True)
145
 
 
 
 
 
146
  # App Header
147
- col1, col2, col3 = st.columns([1, 3, 1])
148
- with col2:
149
- st.markdown('<h1 class="main-header">πŸ“š Base Course Personalization</h1>', unsafe_allow_html=True)
150
- st.markdown("""
151
- Complete this form to tailor your learning experience to your preferences.
152
- Your personalized course will be generated based on the information you provide below.
153
- """)
154
 
155
  # Main Form
156
  with st.form("personalization_form", clear_on_submit=False):
157
- # Personal Information Section
158
- st.markdown('<div class="section-header">πŸ‘€ Personal Details</div>', unsafe_allow_html=True)
159
 
160
  col1, col2 = st.columns(2)
161
  with col1:
162
- user_name = st.text_input("Full Name", placeholder="Enter your full name")
163
- user_age = st.number_input("Age", min_value=10, max_value=100, value=22)
164
 
165
  with col2:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  user_gender = st.selectbox(
167
  "Gender",
168
  ["male", "female", "other"],
169
  index=0,
170
  format_func=lambda x: x.capitalize()
171
  )
 
 
172
  tech_knowledge = st.select_slider(
173
  "Technical Knowledge",
174
  options=["beginner", "intermediate", "advanced"],
175
  value="beginner"
176
  )
177
-
 
 
 
 
 
 
 
 
178
  st.markdown('<div class="section-header">🎯 Preferences</div>', unsafe_allow_html=True)
179
  col1, col2 = st.columns(2)
180
 
@@ -182,41 +261,25 @@ with st.form("personalization_form", clear_on_submit=False):
182
  preferred_activity = st.text_area(
183
  "Preferred Activities",
184
  placeholder="e.g., movies, painting, shopping",
 
185
  help="Enter activities separated by commas"
186
  )
187
- physical_activities = st.text_area(
188
- "Physical Activities",
189
- placeholder="e.g., badminton, cricket, yoga",
190
- help="Enter activities separated by commas"
191
- )
192
-
193
- with col2:
194
  food = st.text_area(
195
  "Food Preferences",
196
  placeholder="e.g., vegetarian, paneer, pizza",
 
197
  help="Enter food items separated by commas"
198
  )
199
 
200
- # Learning Style Section
201
- st.markdown('<div class="section-header">πŸŽ“ Learning Preferences</div>', unsafe_allow_html=True)
202
-
203
- learning_style = st.radio(
204
- "Learning Style",
205
- ["visual", "auditory", "kinesthetic"],
206
- index=0,
207
- help="Visual: learn by seeing, Auditory: learn by hearing, Kinesthetic: learn by doing",
208
- horizontal=True,
209
- format_func=lambda x: x.capitalize()
210
- )
211
-
212
- with st.expander("Learn more about learning styles"):
213
- st.info("""
214
- - **Visual learners** prefer images, diagrams, and spatial understanding
215
- - **Auditory learners** learn best through listening and verbal instructions
216
- - **Kinesthetic learners** prefer hands-on activities and learning by doing
217
- """)
218
-
219
- # Language Settings Section
220
  st.markdown('<div class="section-header">πŸ—£οΈ Language & Voice Settings</div>', unsafe_allow_html=True)
221
 
222
  col1, col2, col3 = st.columns(3)
@@ -239,32 +302,45 @@ with st.form("personalization_form", clear_on_submit=False):
239
  with col3:
240
  tts_voice = st.selectbox(
241
  "Voice Style",
242
- ["echo", "soprano", "alto", "robotic"],
243
- index=0,
244
  format_func=lambda x: x.capitalize()
245
  )
246
 
247
- toggle_hinglish = st.toggle("Enable Hinglish", value=True, help="Mix of Hindi and English")
 
 
 
 
248
 
249
- # Course Settings Section
250
- st.markdown('<div class="section-header">πŸ’» Technical Preferences</div>', unsafe_allow_html=True)
251
 
252
- programming_language = st.selectbox(
253
- "Programming Language",
254
- ["python", "java", "javascript", "c++", "go"],
255
- index=0,
256
- format_func=lambda x: x.capitalize()
257
- )
258
-
259
- # Show sample lesson structure
260
- with st.expander("πŸ“‹ Sample Course Structure"):
261
- st.markdown("""
262
- ### Introduction to Flask
263
- 1. What is Flask
264
- 2. Setting Up Flask Environment
265
- 3. Understanding Flask Project Structure
266
- """)
 
 
 
 
 
 
 
267
 
 
 
268
  # Submit button
269
  st.markdown("<br>", unsafe_allow_html=True)
270
  col1, col2, col3 = st.columns([1, 2, 1])
@@ -276,111 +352,157 @@ if submitted:
276
  # Validate inputs
277
  if not user_name:
278
  st.error("Please enter your name")
279
- elif not preferred_activity:
280
- st.warning("Adding preferred activities will help us personalize your content better")
281
  else:
282
  # Show loading state
283
  with st.spinner("Generating your personalized course..."):
284
  time.sleep(1.5) # Simulating API call delay
285
 
286
- # Create payload
287
- payload = {
288
- "personalization_id": 100,
289
- "user_id": 30,
290
- "course_id": 47,
291
- "total_videos": 3,
292
- "created_at": datetime.utcnow().isoformat(),
293
- "user_profile": {
294
- "personalized": True,
295
- "user_name": user_name,
296
- "user_age": user_age,
297
- "user_gender": user_gender,
298
- "user_tech_knowledge": tech_knowledge,
299
- "user_preferred_activity": preferred_activity,
300
- "user_food": food,
301
- "user_physical_activities": physical_activities,
302
- "learning_style": learning_style,
303
- "target_language": target_language,
304
- "tts_gender": tts_gender,
305
- "tts_voice": tts_voice,
306
- "toggle_hinglish": toggle_hinglish,
307
- "run_visualization": False,
308
- "subtitle": "",
309
- "age_group": "18-25",
310
- },
311
- "topics": [
312
- {
313
- "topic_id": 10834,
314
- "topic_title": "Setting Up Flask Environment",
315
- "chapter_id": 647,
316
- "chapter_title": "Introduction to Flask",
317
- "course_id": 47,
318
- "video_url": "https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/1729064365.mp4",
319
- "video_duration": 462,
320
- "sequence_number": 2
321
- },
322
- {
323
- "topic_id": 10835,
324
- "topic_title": "Understanding Flask Project Structure",
325
- "chapter_id": 647,
326
- "chapter_title": "Introduction to Flask",
327
- "course_id": 47,
328
- "video_url": "https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/1729064412.mp4",
329
- "video_duration": 429,
330
- "sequence_number": 3
331
- },
332
- {
333
- "topic_id": 10833,
334
- "topic_title": "What is Flask",
335
- "chapter_id": 647,
336
- "chapter_title": "Introduction to Flask",
337
- "course_id": 47,
338
- "video_url": "https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/1729064322.mp4",
339
- "video_duration": 410,
340
- "sequence_number": 1
341
  }
342
- ],
343
- "settings": {
344
- "target_language": target_language,
345
- "tts_gender": tts_gender,
346
- "tts_voice": tts_voice,
347
- "toggle_hinglish": toggle_hinglish,
348
- "run_visualization": False,
349
- "subtitle": "",
350
- "programming_language": programming_language,
351
  }
352
- }
 
 
 
 
 
 
 
 
 
 
353
 
354
  # Make API call
355
  try:
356
- response = requests.post(API_ENDPOINT, json=payload)
 
 
 
 
357
 
358
  if response.status_code == 200:
359
- st.success(f"Course personalized successfully for {user_name}!")
 
 
 
 
 
 
360
 
361
  # Display results in a clean format
362
- st.markdown("### πŸŽ‰ Your personalized course is ready!")
363
  st.markdown(f"""
364
- **Course**: Introduction to Flask
 
365
  **Programming Language**: {programming_language.capitalize()}
366
  **Learning Style**: {learning_style.capitalize()}
367
- **Voice**: {tts_voice.capitalize()} ({tts_gender.capitalize()})
 
368
  """)
369
 
 
 
 
 
 
 
370
  # Display API response
371
- st.markdown('<div class="section-header">🌍 API Response</div>', unsafe_allow_html=True)
372
  st.markdown('<div class="api-response">', unsafe_allow_html=True)
373
- st.json(response.json())
374
  st.markdown('</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
375
  else:
376
- st.error(f"API Error: {response.status_code} - {response.text}")
 
 
 
 
 
 
 
377
  except Exception as e:
378
- st.error(f"API call failed: {e}")
379
 
380
- # Show local payload as fallback
381
- st.warning("Using local data as fallback:")
382
  st.json(payload)
383
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  # Footer
385
  st.markdown("---")
386
- st.caption("Β© 2025 Base Course Personalization | All Rights Reserved")
 
 
 
 
 
 
 
3
  from datetime import datetime
4
  import time
5
  import requests
6
+ import boto3
7
+ import uuid
8
 
9
+ # API endpoint - Replace with your actual endpoint
10
+ API_ENDPOINT = "https://oau6sljd4l.execute-api.ap-south-1.amazonaws.com/production/process"
11
+
12
+ # DynamoDB configuration for session tracking
13
+ DYNAMODB_REGION = "ap-south-1"
14
+ SESSION_TABLE = "SessionTracking"
15
 
16
  # Set page configuration
17
  st.set_page_config(
 
52
  font-weight: 600;
53
  color: var(--header-color);
54
  margin-bottom: 1rem;
55
+ text-align: center;
56
  }
57
 
58
  .section-header {
 
89
  border-color: var(--border-color);
90
  }
91
 
92
+ .stTextInput > div > div > input,
93
+ .stNumberInput > div > div > input,
 
 
 
 
 
 
 
 
 
94
  .stTextArea > div > div > textarea {
95
  background-color: var(--background-color);
96
  color: var(--text-color);
 
113
  border-color: var(--border-color);
114
  }
115
 
 
 
 
 
 
116
  /* API Response Container */
117
  .api-response {
118
  background-color: #1A1A1A;
 
121
  border-left: 4px solid var(--accent-color);
122
  }
123
 
124
+ .session-info {
125
+ background-color: var(--card-background);
126
+ padding: 1rem;
127
+ border-radius: 8px;
128
+ margin: 1rem 0;
129
+ border: 1px solid var(--border-color);
 
 
 
 
 
130
  }
131
  </style>
132
  """, unsafe_allow_html=True)
133
 
134
+ # Initialize session state
135
+ if 'session_ids' not in st.session_state:
136
+ st.session_state.session_ids = []
137
+
138
  # App Header
139
+ st.markdown('<h1 class="main-header">πŸ“š Base Course Personalization</h1>', unsafe_allow_html=True)
140
+ st.markdown("""
141
+ <div style="text-align: center; margin-bottom: 2rem;">
142
+ Complete this form to tailor your learning experience to your preferences.<br>
143
+ Your personalized course will be generated based on the information you provide below.
144
+ </div>
145
+ """, unsafe_allow_html=True)
146
 
147
  # Main Form
148
  with st.form("personalization_form", clear_on_submit=False):
149
+ # Course Information Section
150
+ st.markdown('<div class="section-header">πŸ“š Course Information</div>', unsafe_allow_html=True)
151
 
152
  col1, col2 = st.columns(2)
153
  with col1:
154
+ course_id = st.number_input("Course ID", min_value=1, value=47, help="Enter the course ID")
155
+ user_id = st.number_input("User ID", min_value=1, value=30, help="Enter your user ID")
156
 
157
  with col2:
158
+ personalization_id = st.number_input("Personalization ID", min_value=1, value=100, help="Enter personalization ID")
159
+
160
+ # Topics Section
161
+ st.markdown('<div class="section-header">πŸ“‹ Topics Configuration</div>', unsafe_allow_html=True)
162
+
163
+ # Option to choose single or multiple topics
164
+ topic_mode = st.radio(
165
+ "Topic Mode",
166
+ ["Single Topic", "Multiple Topics"],
167
+ horizontal=True,
168
+ help="Choose whether to process one topic or multiple topics"
169
+ )
170
+
171
+ if topic_mode == "Single Topic":
172
+ st.subheader("Single Topic Details")
173
+ col1, col2 = st.columns(2)
174
+ with col1:
175
+ single_topic_id = st.number_input("Topic ID", min_value=1, value=10834)
176
+ single_topic_title = st.text_input("Topic Title", value="Setting Up Flask Environment")
177
+ with col2:
178
+ single_chapter_id = st.number_input("Chapter ID", min_value=1, value=647)
179
+ single_chapter_title = st.text_input("Chapter Title", value="Introduction to Flask")
180
+
181
+ single_video_url = st.text_input(
182
+ "Video URL",
183
+ value="https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/1729064365.mp4"
184
+ )
185
+ col1, col2 = st.columns(2)
186
+ with col1:
187
+ single_video_duration = st.number_input("Video Duration (seconds)", min_value=1, value=462)
188
+ with col2:
189
+ single_sequence_number = st.number_input("Sequence Number", min_value=1, value=1)
190
+
191
+ else:
192
+ st.subheader("Multiple Topics")
193
+ num_topics = st.number_input("Number of Topics", min_value=1, max_value=10, value=3)
194
+
195
+ topics_data = []
196
+ for i in range(num_topics):
197
+ with st.expander(f"Topic {i+1}"):
198
+ col1, col2 = st.columns(2)
199
+ with col1:
200
+ topic_id = st.number_input(f"Topic ID {i+1}", min_value=1, value=10833+i, key=f"topic_id_{i}")
201
+ topic_title = st.text_input(f"Topic Title {i+1}",
202
+ value=["What is Flask", "Setting Up Flask Environment", "Understanding Flask Project Structure"][i] if i < 3 else f"Topic {i+1}",
203
+ key=f"topic_title_{i}")
204
+ with col2:
205
+ chapter_id = st.number_input(f"Chapter ID {i+1}", min_value=1, value=647, key=f"chapter_id_{i}")
206
+ chapter_title = st.text_input(f"Chapter Title {i+1}", value="Introduction to Flask", key=f"chapter_title_{i}")
207
+
208
+ video_url = st.text_input(f"Video URL {i+1}",
209
+ value=f"https://techlearn-dev.s3.ap-south-1.amazonaws.com/course_videos/47/647/172906{4322+i*50}.mp4",
210
+ key=f"video_url_{i}")
211
+ col1, col2 = st.columns(2)
212
+ with col1:
213
+ video_duration = st.number_input(f"Video Duration {i+1} (seconds)", min_value=1, value=410+i*20, key=f"video_duration_{i}")
214
+ with col2:
215
+ sequence_number = st.number_input(f"Sequence Number {i+1}", min_value=1, value=i+1, key=f"sequence_number_{i}")
216
+
217
+ topics_data.append({
218
+ "topic_id": topic_id,
219
+ "topic_title": topic_title,
220
+ "chapter_id": chapter_id,
221
+ "chapter_title": chapter_title,
222
+ "video_url": video_url,
223
+ "video_duration": video_duration,
224
+ "sequence_number": sequence_number,
225
+ "course_id": course_id
226
+ })
227
+
228
+ # Personal Information Section
229
+ st.markdown('<div class="section-header">πŸ‘€ User Profile</div>', unsafe_allow_html=True)
230
+
231
+ col1, col2 = st.columns(2)
232
+ with col1:
233
+ user_name = st.text_input("Full Name", placeholder="Enter your full name", value="John Doe")
234
+ user_age = st.number_input("Age", min_value=10, max_value=100, value=22)
235
  user_gender = st.selectbox(
236
  "Gender",
237
  ["male", "female", "other"],
238
  index=0,
239
  format_func=lambda x: x.capitalize()
240
  )
241
+
242
+ with col2:
243
  tech_knowledge = st.select_slider(
244
  "Technical Knowledge",
245
  options=["beginner", "intermediate", "advanced"],
246
  value="beginner"
247
  )
248
+ learning_style = st.radio(
249
+ "Learning Style",
250
+ ["visual", "auditory", "kinesthetic"],
251
+ index=0,
252
+ horizontal=True,
253
+ format_func=lambda x: x.capitalize()
254
+ )
255
+
256
+ # Preferences Section
257
  st.markdown('<div class="section-header">🎯 Preferences</div>', unsafe_allow_html=True)
258
  col1, col2 = st.columns(2)
259
 
 
261
  preferred_activity = st.text_area(
262
  "Preferred Activities",
263
  placeholder="e.g., movies, painting, shopping",
264
+ value="movies, painting, shopping",
265
  help="Enter activities separated by commas"
266
  )
 
 
 
 
 
 
 
267
  food = st.text_area(
268
  "Food Preferences",
269
  placeholder="e.g., vegetarian, paneer, pizza",
270
+ value="vegetarian, paneer, pizza",
271
  help="Enter food items separated by commas"
272
  )
273
 
274
+ with col2:
275
+ physical_activities = st.text_area(
276
+ "Physical Activities",
277
+ placeholder="e.g., badminton, cricket, yoga",
278
+ value="badminton, cricket, yoga",
279
+ help="Enter activities separated by commas"
280
+ )
281
+
282
+ # Language & Voice Settings Section
 
 
 
 
 
 
 
 
 
 
 
283
  st.markdown('<div class="section-header">πŸ—£οΈ Language & Voice Settings</div>', unsafe_allow_html=True)
284
 
285
  col1, col2, col3 = st.columns(3)
 
302
  with col3:
303
  tts_voice = st.selectbox(
304
  "Voice Style",
305
+ ["echo", "soprano", "alto", "robotic", "onyx"],
306
+ index=4, # Default to "onyx" as used in backend
307
  format_func=lambda x: x.capitalize()
308
  )
309
 
310
+ col1, col2 = st.columns(2)
311
+ with col1:
312
+ toggle_hinglish = st.toggle("Enable Hinglish", value=True, help="Mix of Hindi and English")
313
+ with col2:
314
+ run_visualization = st.toggle("Run Visualization", value=False, help="Enable visualization features")
315
 
316
+ # Technical Settings Section
317
+ st.markdown('<div class="section-header">πŸ’» Technical Settings</div>', unsafe_allow_html=True)
318
 
319
+ col1, col2, col3 = st.columns(3)
320
+ with col1:
321
+ programming_language = st.selectbox(
322
+ "Programming Language",
323
+ ["python", "java", "javascript", "c++", "go"],
324
+ index=0,
325
+ format_func=lambda x: x.capitalize()
326
+ )
327
+ with col2:
328
+ slide_colour = st.selectbox(
329
+ "Slide Color",
330
+ ["blue", "red", "green", "purple", "orange"],
331
+ index=0,
332
+ format_func=lambda x: x.capitalize()
333
+ )
334
+ with col3:
335
+ video_type = st.selectbox(
336
+ "Video Type",
337
+ ["personalised_video", "standard_video"],
338
+ index=0,
339
+ format_func=lambda x: x.replace('_', ' ').title()
340
+ )
341
 
342
+ subtitle = st.text_input("Subtitle", placeholder="Optional subtitle for the video", value="")
343
+
344
  # Submit button
345
  st.markdown("<br>", unsafe_allow_html=True)
346
  col1, col2, col3 = st.columns([1, 2, 1])
 
352
  # Validate inputs
353
  if not user_name:
354
  st.error("Please enter your name")
355
+ elif topic_mode == "Single Topic" and not single_topic_title:
356
+ st.error("Please enter a topic title")
357
  else:
358
  # Show loading state
359
  with st.spinner("Generating your personalized course..."):
360
  time.sleep(1.5) # Simulating API call delay
361
 
362
+ # Create user profile
363
+ user_profile = {
364
+ "personalized": True,
365
+ "user_name": user_name,
366
+ "user_age": user_age,
367
+ "user_gender": user_gender,
368
+ "user_tech_knowledge": tech_knowledge,
369
+ "user_preferred_activity": preferred_activity,
370
+ "user_food": food,
371
+ "user_physical_activities": physical_activities,
372
+ "learning_style": learning_style,
373
+ "target_language": target_language,
374
+ "tts_gender": tts_gender,
375
+ "tts_voice": tts_voice,
376
+ "toggle_hinglish": toggle_hinglish,
377
+ "run_visualization": run_visualization,
378
+ "subtitle": subtitle,
379
+ "age_group": "18-25" if user_age <= 25 else "26-35" if user_age <= 35 else "35+"
380
+ }
381
+
382
+ # Create settings
383
+ settings = {
384
+ "target_language": target_language,
385
+ "tts_gender": tts_gender,
386
+ "tts_voice": tts_voice,
387
+ "toggle_hinglish": toggle_hinglish,
388
+ "run_visualization": run_visualization,
389
+ "subtitle": subtitle,
390
+ "programming_language": programming_language,
391
+ "slide_colour": slide_colour,
392
+ "video_type": video_type
393
+ }
394
+
395
+ # Create payload based on topic mode
396
+ if topic_mode == "Single Topic":
397
+ payload = {
398
+ "personalization_id": personalization_id,
399
+ "user_profile": user_profile,
400
+ "settings": settings,
401
+ "topic_data": {
402
+ "topic_id": single_topic_id,
403
+ "topic_title": single_topic_title,
404
+ "chapter_id": single_chapter_id,
405
+ "chapter_title": single_chapter_title,
406
+ "course_id": course_id,
407
+ "video_url": single_video_url,
408
+ "video_duration": single_video_duration,
409
+ "sequence_number": single_sequence_number
 
 
 
 
 
 
 
410
  }
 
 
 
 
 
 
 
 
 
411
  }
412
+ else:
413
+ payload = {
414
+ "personalization_id": personalization_id,
415
+ "user_id": user_id,
416
+ "course_id": course_id,
417
+ "total_videos": len(topics_data),
418
+ "created_at": datetime.utcnow().isoformat(),
419
+ "user_profile": user_profile,
420
+ "topics": topics_data,
421
+ "settings": settings
422
+ }
423
 
424
  # Make API call
425
  try:
426
+ headers = {
427
+ 'Content-Type': 'application/json'
428
+ }
429
+
430
+ response = requests.post(API_ENDPOINT, json=payload, headers=headers, timeout=30)
431
 
432
  if response.status_code == 200:
433
+ response_data = response.json()
434
+ session_ids = response_data.get("session_ids", [])
435
+
436
+ st.success(f"Course personalization started successfully for {user_name}!")
437
+
438
+ # Store session IDs in session state
439
+ st.session_state.session_ids.extend(session_ids)
440
 
441
  # Display results in a clean format
442
+ st.markdown("### πŸŽ‰ Your personalized course generation has started!")
443
  st.markdown(f"""
444
+ **User**: {user_name}
445
+ **Course ID**: {course_id}
446
  **Programming Language**: {programming_language.capitalize()}
447
  **Learning Style**: {learning_style.capitalize()}
448
+ **Voice**: {tts_voice.capitalize()} ({tts_gender.capitalize()})
449
+ **Topics**: {len(topics_data) if topic_mode == "Multiple Topics" else 1}
450
  """)
451
 
452
+ # Display session IDs
453
+ if session_ids:
454
+ st.markdown("### πŸ” Session IDs for Tracking")
455
+ for i, session_id in enumerate(session_ids, 1):
456
+ st.markdown(f'<div class="session-info"><strong>Session {i}:</strong> <code>{session_id}</code></div>', unsafe_allow_html=True)
457
+
458
  # Display API response
459
+ st.markdown('<div class="section-header">πŸ“Š API Response</div>', unsafe_allow_html=True)
460
  st.markdown('<div class="api-response">', unsafe_allow_html=True)
461
+ st.json(response_data)
462
  st.markdown('</div>', unsafe_allow_html=True)
463
+
464
+ # Information about tracking
465
+ st.info(f"""
466
+ πŸ’‘ **Tracking Information**
467
+ You can track the progress of your video generation using the session IDs above.
468
+ The processing status will be updated in DynamoDB table: `{SESSION_TABLE}`
469
+ Region: `{DYNAMODB_REGION}`
470
+ """)
471
+
472
  else:
473
+ st.error(f"API Error: {response.status_code}")
474
+ if response.text:
475
+ st.error(f"Error Details: {response.text}")
476
+
477
+ except requests.exceptions.Timeout:
478
+ st.error("Request timed out. Please try again later.")
479
+ except requests.exceptions.ConnectionError:
480
+ st.error("Connection error. Please check your internet connection.")
481
  except Exception as e:
482
+ st.error(f"API call failed: {str(e)}")
483
 
484
+ # Show payload for debugging
485
+ st.warning("Request payload for debugging:")
486
  st.json(payload)
487
 
488
+ # Display previous session IDs if any
489
+ if st.session_state.session_ids:
490
+ st.markdown("---")
491
+ st.markdown("### πŸ“‹ Previous Session IDs")
492
+ for i, session_id in enumerate(st.session_state.session_ids, 1):
493
+ st.markdown(f'<div class="session-info"><strong>Session {i}:</strong> <code>{session_id}</code></div>', unsafe_allow_html=True)
494
+
495
+ # Button to clear session history
496
+ if st.button("Clear Session History"):
497
+ st.session_state.session_ids = []
498
+ st.rerun()
499
+
500
  # Footer
501
  st.markdown("---")
502
+ st.markdown(f"""
503
+ <div style="text-align: center; color: #888888;">
504
+ Β© 2025 Base Course Personalization | All Rights Reserved<br>
505
+ <small>API Endpoint: {API_ENDPOINT}</small><br>
506
+ <small>Session Tracking: {SESSION_TABLE} ({DYNAMODB_REGION})</small>
507
+ </div>
508
+ """, unsafe_allow_html=True)