MeghanaArakkal commited on
Commit
6d3215d
Β·
verified Β·
1 Parent(s): 0cbd969

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -48
app.py CHANGED
@@ -297,21 +297,6 @@ with gr.Blocks(title="Nova Premier Red Team Chat") as demo:
297
  ## Nova Premier Red Team Chat πŸ”΄πŸ€–
298
  Upload an image *(optional)*, ask a question, and continue the conversation.
299
 
300
- **Multi-User Support:**
301
- - πŸ‘₯ Each browser tab/session gets a unique conversation ID
302
- - πŸ”’ Conversations are isolated between users
303
- - 🚫 **Race condition safe** - sequential dataset updates prevent data loss
304
- - ⚑ Real-time image upload with direct URLs
305
-
306
- **Logging Features:**
307
- - πŸ’Ύ **Queue-based logging** prevents concurrent write conflicts
308
- - πŸ”„ **Context preservation** - entire chat context maintained
309
- - πŸ“Έ **Image tracking** - direct links to uploaded images
310
- - 🏷️ **Session management** - unique session ID per conversation
311
-
312
- **Storage:**
313
- - πŸ€— HF Dataset: {"βœ… Enabled with queue-based safety" if HF_TOKEN else "❌ Disabled (set HF_TOKEN)"} - Repo: `{REPO_ID}`
314
- - πŸ–ΌοΈ Images: {"βœ… Uploaded with direct URLs" if HF_TOKEN else "❌ Local only"}
315
  """
316
  )
317
 
@@ -465,48 +450,48 @@ with gr.Blocks(title="Nova Premier Red Team Chat") as demo:
465
  )
466
 
467
  # Add info about the race-condition-safe logging
468
- gr.Markdown(
469
- f"""
470
- ### πŸ›‘οΈ Race Condition Protection
471
 
472
- **Problem Solved**: Multiple users uploading simultaneously could overwrite each other's data.
473
 
474
- **Solution**: Queue-based sequential processing:
475
- - πŸ“ Each conversation update goes into a queue
476
- - πŸ”§ Background worker processes updates one at a time
477
- - 🚫 No concurrent dataset writes = no data loss
478
- - ⚑ UI stays responsive while background worker handles persistence
479
 
480
- ### πŸ“Š Logging Architecture
481
 
482
- 1. **Immediate**: Local JSONL files for instant access
483
- 2. **Queued**: HF dataset updates processed sequentially
484
- 3. **Direct**: Image uploads happen immediately for real URLs
485
- 4. **Safe**: Each session overwrites only its own record
486
 
487
- ### πŸ–ΌοΈ Image Storage Format
488
 
489
- Images: `images/{{session_id}}_{{msg_idx:03d}}_{{timestamp}}_{{random}}.png`
490
- - **session_id**: First 8 chars of session UUID
491
- - **msg_idx**: 3-digit message number (000, 001, 002...)
492
- - **timestamp**: UTC timestamp when uploaded
493
- - **random**: 8-char random suffix for uniqueness
494
 
495
- ### πŸ” Dataset Structure
496
 
497
- **HF Dataset**: [https://huggingface.co/datasets/{REPO_ID}](https://huggingface.co/datasets/{REPO_ID})
498
- - One record per session (updated as conversation progresses)
499
- - **Images folder**: [https://huggingface.co/datasets/{REPO_ID}/tree/main/images](https://huggingface.co/datasets/{REPO_ID}/tree/main/images)
500
- - Filter by `session_id` to find specific conversations
501
- - Image URLs in conversation data link directly to files
502
 
503
- **Benefits**:
504
- - βœ… No data loss from concurrent users
505
- - βœ… Real image URLs immediately available
506
- - βœ… Complete conversation context preserved
507
- - βœ… Scalable to many simultaneous users
508
- """
509
- )
510
 
511
  # ====== Launch ====== #
512
  if __name__ == "__main__":
 
297
  ## Nova Premier Red Team Chat πŸ”΄πŸ€–
298
  Upload an image *(optional)*, ask a question, and continue the conversation.
299
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  """
301
  )
302
 
 
450
  )
451
 
452
  # Add info about the race-condition-safe logging
453
+ # gr.Markdown(
454
+ # f"""
455
+ # ### πŸ›‘οΈ Race Condition Protection
456
 
457
+ # **Problem Solved**: Multiple users uploading simultaneously could overwrite each other's data.
458
 
459
+ # **Solution**: Queue-based sequential processing:
460
+ # - πŸ“ Each conversation update goes into a queue
461
+ # - πŸ”§ Background worker processes updates one at a time
462
+ # - 🚫 No concurrent dataset writes = no data loss
463
+ # - ⚑ UI stays responsive while background worker handles persistence
464
 
465
+ # ### πŸ“Š Logging Architecture
466
 
467
+ # 1. **Immediate**: Local JSONL files for instant access
468
+ # 2. **Queued**: HF dataset updates processed sequentially
469
+ # 3. **Direct**: Image uploads happen immediately for real URLs
470
+ # 4. **Safe**: Each session overwrites only its own record
471
 
472
+ # ### πŸ–ΌοΈ Image Storage Format
473
 
474
+ # Images: `images/{{session_id}}_{{msg_idx:03d}}_{{timestamp}}_{{random}}.png`
475
+ # - **session_id**: First 8 chars of session UUID
476
+ # - **msg_idx**: 3-digit message number (000, 001, 002...)
477
+ # - **timestamp**: UTC timestamp when uploaded
478
+ # - **random**: 8-char random suffix for uniqueness
479
 
480
+ # ### πŸ” Dataset Structure
481
 
482
+ # **HF Dataset**: [https://huggingface.co/datasets/{REPO_ID}](https://huggingface.co/datasets/{REPO_ID})
483
+ # - One record per session (updated as conversation progresses)
484
+ # - **Images folder**: [https://huggingface.co/datasets/{REPO_ID}/tree/main/images](https://huggingface.co/datasets/{REPO_ID}/tree/main/images)
485
+ # - Filter by `session_id` to find specific conversations
486
+ # - Image URLs in conversation data link directly to files
487
 
488
+ # **Benefits**:
489
+ # - βœ… No data loss from concurrent users
490
+ # - βœ… Real image URLs immediately available
491
+ # - βœ… Complete conversation context preserved
492
+ # - βœ… Scalable to many simultaneous users
493
+ # """
494
+ # )
495
 
496
  # ====== Launch ====== #
497
  if __name__ == "__main__":