shukdevdatta123 commited on
Commit
731ec12
Β·
verified Β·
1 Parent(s): e761598

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +252 -6
app.py CHANGED
@@ -221,8 +221,255 @@ custom_css = """
221
  }
222
  """
223
 
224
- # Create the Gradio interface
225
- with gr.Blocks(css=custom_css, title="Memory Palace Builder", theme=gr.themes.Soft()) as app:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  gr.HTML("""
227
  <div class="palace-header">
228
  <h1>🏰 Memory Palace Builder</h1>
@@ -230,6 +477,9 @@ with gr.Blocks(css=custom_css, title="Memory Palace Builder", theme=gr.themes.So
230
  </div>
231
  """)
232
 
 
 
 
233
  with gr.Tab("πŸ”‘ Setup"):
234
  gr.HTML("<div class='section-header'><h3>API Configuration</h3></div>")
235
 
@@ -270,7 +520,6 @@ with gr.Blocks(css=custom_css, title="Memory Palace Builder", theme=gr.themes.So
270
  placeholder="""Describe your space in detail. For example:
271
 
272
  'My apartment has a front door that opens to a small hallway. To the left is the living room with a big window, couch, and TV. Straight ahead is the kitchen with white cabinets and a small dining table. The bedroom is to the right with a bed, dresser, and closet. The bathroom is next to the bedroom with a blue shower curtain.'
273
-
274
  Include layouts, colors, furniture, lighting, and any distinctive features.""",
275
  info="The more detail you provide, the better your memory palace will be!"
276
  )
@@ -311,11 +560,8 @@ Include layouts, colors, furniture, lighting, and any distinctive features.""",
311
  lines=8,
312
  label="Content to Memorize",
313
  placeholder="""Enter the information you want to memorize. Examples:
314
-
315
  For Language: 'French words: maison (house), chat (cat), livre (book), eau (water), rouge (red)'
316
-
317
  For History: 'World War II timeline: 1939 - Germany invades Poland, 1941 - Pearl Harbor attack, 1944 - D-Day landings, 1945 - End of war'
318
-
319
  For Programming: 'Python list methods: append(), remove(), pop(), insert(), index(), count()'""",
320
  info="Be specific and organized - this will be mapped to your space!"
321
  )
 
221
  }
222
  """
223
 
224
+ def create_sample_inputs_accordion():
225
+ """Create a Gradio accordion with all sample inputs for testing"""
226
+
227
+ with gr.Accordion("πŸ“‹ Sample Test Inputs & Examples", open=False):
228
+ gr.HTML("""
229
+ <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 15px; border-radius: 10px; margin-bottom: 20px;">
230
+ <h2 style="margin: 0; text-align: center;">🏰 Memory Palace Builder - Test Guide</h2>
231
+ <p style="margin: 10px 0 0 0; text-align: center;">Copy these examples to test each feature</p>
232
+ </div>
233
+ """)
234
+
235
+ # API Setup Section
236
+ with gr.Accordion("πŸ”‘ API Setup", open=False):
237
+ gr.HTML("""
238
+ <div style="padding: 10px; background-color: #f8f9fa; border-radius: 5px;">
239
+ <h4>OpenRouter API Key:</h4>
240
+ <ul>
241
+ <li>Get your free API key from: <a href="https://openrouter.ai/" target="_blank">https://openrouter.ai/</a></li>
242
+ <li>Paste it in the password field and click "Validate API Key"</li>
243
+ </ul>
244
+ </div>
245
+ """)
246
+
247
+ # Space Analysis Section
248
+ with gr.Accordion("πŸ—ΊοΈ Space Analysis Examples", open=False):
249
+ with gr.Tab("🏠 Home/Apartment"):
250
+ gr.HTML("<h4>Space Type: Home/Apartment</h4>")
251
+ sample_home = gr.Textbox(
252
+ label="Sample Home Description",
253
+ value="""My studio apartment has a single main room with distinct areas. When you enter through the front door, there's a small entryway with a coat closet on the left. The living area has a comfortable blue sofa facing a 55-inch TV mounted on the white wall. Behind the sofa is a small dining table with two wooden chairs next to a large window that faces east and gets bright morning sunlight.
254
+
255
+ The kitchen area is along the right wall with white cabinets, a black granite countertop, a stainless steel refrigerator, and a small microwave. There's a distinctive red coffee maker on the counter that I use every morning.
256
+
257
+ The bedroom area is separated by a tall bookshelf filled with novels and textbooks. My bed has a navy blue comforter and sits against the far wall next to a wooden nightstand with a lamp that has a green shade.
258
+
259
+ The bathroom is compact with white tiles, a shower with a clear glass door, and a mirror with Hollywood-style lights around it. There's always a lavender scent from the candle on the sink counter.""",
260
+ lines=8,
261
+ max_lines=12
262
+ )
263
+
264
+ with gr.Tab("🏒 Office/Workplace"):
265
+ gr.HTML("<h4>Space Type: Office/Workplace</h4>")
266
+ sample_office = gr.Textbox(
267
+ label="Sample Office Description",
268
+ value="""My office is a rectangular room on the 5th floor with a large window overlooking the city park. My desk is positioned diagonally in the corner near the window - it's a modern white desk with a dual monitor setup and a mechanical keyboard that makes a satisfying clicking sound.
269
+
270
+ Behind my chair is a tall filing cabinet with a small cactus plant on top. To my left is a comfortable reading chair with a grey fabric cover next to a small side table where I keep my coffee mug.
271
+
272
+ The opposite wall has a whiteboard covered in colorful sticky notes and project timelines. Below it is a long credenza with three drawers where I store supplies. On top of the credenza are several awards and a photo of my family.
273
+
274
+ Near the door is a coat rack and a small waste basket. The lighting comes from overhead fluorescent lights and a warm desk lamp with an adjustable arm. The carpet is industrial grey, and there's always a faint smell of coffee from the break room down the hall.""",
275
+ lines=8,
276
+ max_lines=12
277
+ )
278
+
279
+ with gr.Tab("🚢 Neighborhood Route"):
280
+ gr.HTML("<h4>Space Type: Neighborhood Route</h4>")
281
+ sample_route = gr.Textbox(
282
+ label="Sample Walking Route Description",
283
+ value="""My daily walking route starts at my house with the red mailbox and proceeds down Maple Street. I pass the old oak tree with the tire swing, then the yellow house with the garden gnomes in the front yard.
284
+
285
+ At the first intersection, there's a stop sign and Mrs. Johnson's house with the purple door and wind chimes. I turn right onto Pine Avenue and walk past the small park with the blue playground and the memorial bench dedicated to local veterans.
286
+
287
+ Continuing straight, I pass the corner grocery store with the neon "OPEN" sign and the barber shop with the classic spinning pole. The route curves left at the fire station with its bright red trucks visible through the glass doors.
288
+
289
+ The final stretch goes past the community center with basketball courts where teenagers often play loud music, then the old church with the tall bell tower and beautiful stained glass windows, before ending back at my street near the bus stop with the green bench and newspaper stand.""",
290
+ lines=8,
291
+ max_lines=12
292
+ )
293
+
294
+ # Learning Content Section
295
+ with gr.Accordion("🏰 Learning Content Examples", open=False):
296
+ with gr.Tab("πŸ—£οΈ Language Vocabulary"):
297
+ gr.HTML("<h4>Content Type: Language Vocabulary | Difficulty: Intermediate</h4>")
298
+ sample_language = gr.Textbox(
299
+ label="Spanish Kitchen Vocabulary",
300
+ value="""Spanish Kitchen Vocabulary:
301
+ - cocina (kitchen) - koh-SEE-nah
302
+ - refrigerador (refrigerator) - reh-free-heh-rah-DOHR
303
+ - estufa (stove) - es-TOO-fah
304
+ - microondas (microwave) - mee-kroh-ON-dahs
305
+ - fregadero (sink) - freh-gah-DEH-roh
306
+ - mesa (table) - MEH-sah
307
+ - silla (chair) - SEE-yah
308
+ - plato (plate) - PLAH-toh
309
+ - vaso (glass) - VAH-soh
310
+ - cuchillo (knife) - koo-CHEE-yoh
311
+ - tenedor (fork) - teh-neh-DOHR
312
+ - cuchara (spoon) - koo-CHAH-rah""",
313
+ lines=8,
314
+ max_lines=15
315
+ )
316
+
317
+ with gr.Tab("πŸ“š Historical Facts"):
318
+ gr.HTML("<h4>Content Type: Historical Facts | Difficulty: Advanced</h4>")
319
+ sample_history = gr.Textbox(
320
+ label="World War II Pacific Theater Timeline",
321
+ value="""World War II Pacific Theater Timeline:
322
+ - December 7, 1941: Pearl Harbor attack - Japan surprises US naval base
323
+ - April 18, 1942: Doolittle Raid - First US bombing of Japanese mainland
324
+ - June 4-7, 1942: Battle of Midway - Decisive US naval victory
325
+ - August 7, 1942: Guadalcanal Campaign begins - First major Allied offensive
326
+ - October 20, 1944: MacArthur returns to Philippines - Battle of Leyte Gulf
327
+ - February 19, 1945: Iwo Jima invasion - Iconic flag raising photo
328
+ - April 1, 1945: Okinawa invasion - Largest Pacific campaign
329
+ - August 6, 1945: Hiroshima atomic bomb - "Little Boy"
330
+ - August 9, 1945: Nagasaki atomic bomb - "Fat Man"
331
+ - August 15, 1945: Japan surrenders - Emperor's radio broadcast""",
332
+ lines=8,
333
+ max_lines=12
334
+ )
335
+
336
+ with gr.Tab("πŸ’» Programming Concepts"):
337
+ gr.HTML("<h4>Content Type: Programming Code | Difficulty: Beginner</h4>")
338
+ sample_programming = gr.Textbox(
339
+ label="Python Data Types and Operations",
340
+ value="""Python Data Types and Operations:
341
+ - int: Whole numbers (5, -3, 0) - Use type(5)
342
+ - float: Decimal numbers (3.14, -2.5) - Use type(3.14)
343
+ - str: Text in quotes ("hello", 'world') - Use len("hello")
344
+ - bool: True or False values - Use type(True)
345
+ - list: Ordered collection [1, 2, 3] - Use append(), remove()
346
+ - dict: Key-value pairs {"name": "John"} - Use keys(), values()
347
+ - tuple: Immutable sequence (1, 2, 3) - Cannot change after creation
348
+ - set: Unique values {1, 2, 3} - Use add(), remove()
349
+
350
+ Common Operations:
351
+ - len() - Get length of object
352
+ - print() - Display output
353
+ - input() - Get user input
354
+ - range() - Generate number sequence""",
355
+ lines=10,
356
+ max_lines=15
357
+ )
358
+
359
+ with gr.Tab("πŸ”¬ Scientific Concepts"):
360
+ gr.HTML("<h4>Content Type: Scientific Concepts | Difficulty: Intermediate</h4>")
361
+ sample_science = gr.Textbox(
362
+ label="Periodic Table First 20 Elements",
363
+ value="""Periodic Table First 20 Elements:
364
+ 1. Hydrogen (H) - Lightest element, fuel for stars
365
+ 2. Helium (He) - Noble gas, makes balloons float
366
+ 3. Lithium (Li) - Soft metal, used in batteries
367
+ 4. Beryllium (Be) - Light metal, toxic to humans
368
+ 5. Boron (B) - Metalloid, used in glass and ceramics
369
+ 6. Carbon (C) - Basis of organic chemistry, diamond/graphite
370
+ 7. Nitrogen (N) - 78% of atmosphere, inert gas
371
+ 8. Oxygen (O) - 21% of atmosphere, essential for life
372
+ 9. Fluorine (F) - Most reactive element, in toothpaste
373
+ 10. Neon (Ne) - Noble gas, glows orange-red in tubes
374
+ 11. Sodium (Na) - Reactive metal, table salt component
375
+ 12. Magnesium (Mg) - Light metal, burns with bright white flame
376
+ 13. Aluminum (Al) - Lightweight metal, common in foil/cans
377
+ 14. Silicon (Si) - Metalloid, major component of computer chips
378
+ 15. Phosphorus (P) - Essential for DNA, glows in dark
379
+ 16. Sulfur (S) - Yellow nonmetal, rotten egg smell
380
+ 17. Chlorine (Cl) - Green gas, table salt component
381
+ 18. Argon (Ar) - Noble gas, used in light bulbs
382
+ 19. Potassium (K) - Soft metal, essential nutrient
383
+ 20. Calcium (Ca) - Metal, essential for bones and teeth""",
384
+ lines=12,
385
+ max_lines=20
386
+ )
387
+
388
+ # Testing Combinations Section
389
+ with gr.Accordion("🎯 Recommended Testing Combinations", open=False):
390
+ gr.HTML("""
391
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; margin: 20px 0;">
392
+ <div style="background: #e8f5e8; padding: 15px; border-radius: 10px; border-left: 4px solid #28a745;">
393
+ <h4 style="color: #155724; margin-top: 0;">🟒 Easy Test</h4>
394
+ <ul style="margin: 0;">
395
+ <li><strong>Space:</strong> Home/Apartment</li>
396
+ <li><strong>Content:</strong> Programming Concepts</li>
397
+ <li><strong>Difficulty:</strong> Beginner</li>
398
+ </ul>
399
+ </div>
400
+
401
+ <div style="background: #fff3cd; padding: 15px; border-radius: 10px; border-left: 4px solid #ffc107;">
402
+ <h4 style="color: #856404; margin-top: 0;">🟑 Medium Test</h4>
403
+ <ul style="margin: 0;">
404
+ <li><strong>Space:</strong> Office/Workplace</li>
405
+ <li><strong>Content:</strong> Language Vocabulary</li>
406
+ <li><strong>Difficulty:</strong> Intermediate</li>
407
+ </ul>
408
+ </div>
409
+
410
+ <div style="background: #f8d7da; padding: 15px; border-radius: 10px; border-left: 4px solid #dc3545;">
411
+ <h4 style="color: #721c24; margin-top: 0;">πŸ”΄ Hard Test</h4>
412
+ <ul style="margin: 0;">
413
+ <li><strong>Space:</strong> Neighborhood Route</li>
414
+ <li><strong>Content:</strong> Historical Facts</li>
415
+ <li><strong>Difficulty:</strong> Advanced</li>
416
+ </ul>
417
+ </div>
418
+
419
+ <div style="background: #d1ecf1; padding: 15px; border-radius: 10px; border-left: 4px solid #17a2b8;">
420
+ <h4 style="color: #0c5460; margin-top: 0;">πŸš€ Expert Test</h4>
421
+ <ul style="margin: 0;">
422
+ <li><strong>Space:</strong> Custom detailed description</li>
423
+ <li><strong>Content:</strong> Scientific Concepts</li>
424
+ <li><strong>Difficulty:</strong> Expert</li>
425
+ </ul>
426
+ </div>
427
+ </div>
428
+ """)
429
+
430
+ # Quiz and Features Section
431
+ with gr.Accordion("πŸ“ Quiz Types & Features", open=False):
432
+ gr.HTML("""
433
+ <div style="background-color: #f8f9fa; padding: 15px; border-radius: 8px;">
434
+ <h4>Quiz Types to Test:</h4>
435
+ <ul>
436
+ <li><strong>Quick Review:</strong> 3-5 basic recall questions</li>
437
+ <li><strong>Comprehensive Test:</strong> 8-10 detailed questions covering all content</li>
438
+ <li><strong>Spatial Navigation:</strong> Questions about the palace journey and locations</li>
439
+ <li><strong>Random Recall:</strong> Mixed difficulty questions in random order</li>
440
+ </ul>
441
+
442
+ <h4>Other Features:</h4>
443
+ <ul>
444
+ <li><strong>Study Tips:</strong> Click after creating a palace for personalized strategies</li>
445
+ <li><strong>Export:</strong> Save your palace as JSON for later use</li>
446
+ </ul>
447
+ </div>
448
+ """)
449
+
450
+ # Step-by-step Testing Guide
451
+ with gr.Accordion("πŸ”„ Step-by-Step Testing Guide", open=False):
452
+ gr.HTML("""
453
+ <div style="background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); padding: 20px; border-radius: 10px;">
454
+ <h4 style="margin-top: 0;">🎯 Quick 5-Minute Test:</h4>
455
+ <ol style="line-height: 1.6;">
456
+ <li><strong>Setup:</strong> Add your OpenRouter API key</li>
457
+ <li><strong>Space:</strong> Copy the studio apartment description</li>
458
+ <li><strong>Content:</strong> Use Spanish kitchen vocabulary</li>
459
+ <li><strong>Build:</strong> Set difficulty to "Intermediate" and create palace</li>
460
+ <li><strong>Test:</strong> Generate a "Quick Review" quiz</li>
461
+ <li><strong>Tips:</strong> Get personalized study recommendations</li>
462
+ <li><strong>Export:</strong> Save your first palace</li>
463
+ </ol>
464
+
465
+ <div style="margin-top: 15px; padding: 10px; background-color: rgba(255,255,255,0.7); border-radius: 5px;">
466
+ <strong>πŸ’‘ Pro Tip:</strong> Try different combinations to see how the AI adapts its spatial reasoning to different content types and difficulty levels!
467
+ </div>
468
+ </div>
469
+ """)
470
+
471
+ # Create the enhanced Gradio interface
472
+ with gr.Blocks(css=custom_css, title="Memory Palace Builder Enhanced", theme=gr.themes.Soft()) as app:
473
  gr.HTML("""
474
  <div class="palace-header">
475
  <h1>🏰 Memory Palace Builder</h1>
 
477
  </div>
478
  """)
479
 
480
+ # Add the sample inputs accordion at the top
481
+ create_sample_inputs_accordion()
482
+
483
  with gr.Tab("πŸ”‘ Setup"):
484
  gr.HTML("<div class='section-header'><h3>API Configuration</h3></div>")
485
 
 
520
  placeholder="""Describe your space in detail. For example:
521
 
522
  'My apartment has a front door that opens to a small hallway. To the left is the living room with a big window, couch, and TV. Straight ahead is the kitchen with white cabinets and a small dining table. The bedroom is to the right with a bed, dresser, and closet. The bathroom is next to the bedroom with a blue shower curtain.'
 
523
  Include layouts, colors, furniture, lighting, and any distinctive features.""",
524
  info="The more detail you provide, the better your memory palace will be!"
525
  )
 
560
  lines=8,
561
  label="Content to Memorize",
562
  placeholder="""Enter the information you want to memorize. Examples:
 
563
  For Language: 'French words: maison (house), chat (cat), livre (book), eau (water), rouge (red)'
 
564
  For History: 'World War II timeline: 1939 - Germany invades Poland, 1941 - Pearl Harbor attack, 1944 - D-Day landings, 1945 - End of war'
 
565
  For Programming: 'Python list methods: append(), remove(), pop(), insert(), index(), count()'""",
566
  info="Be specific and organized - this will be mapped to your space!"
567
  )