akhaliq HF Staff commited on
Commit
47250f9
·
1 Parent(s): 5ac5919
Files changed (1) hide show
  1. backend_deploy.py +11 -4
backend_deploy.py CHANGED
@@ -413,12 +413,12 @@ CMD ["npm", "start", "--", "-p", "7860"]
413
  """
414
 
415
 
416
- def extract_space_id_from_history(history: Optional[List[Dict]], username: Optional[str] = None) -> Optional[str]:
417
  """
418
  Extract existing space ID from chat history (for updates after followups/imports)
419
 
420
  Args:
421
- history: Chat history (list of dicts with 'role' and 'content')
422
  username: Current username (to verify ownership of imported spaces)
423
 
424
  Returns:
@@ -432,8 +432,15 @@ def extract_space_id_from_history(history: Optional[List[Dict]], username: Optio
432
 
433
  # Look through history for previous deployments or imports
434
  for msg in history:
435
- role = msg.get('role', '')
436
- content = msg.get('content', '')
 
 
 
 
 
 
 
437
 
438
  # Check assistant messages for deployment confirmations
439
  if role == 'assistant':
 
413
  """
414
 
415
 
416
+ def extract_space_id_from_history(history: Optional[List], username: Optional[str] = None) -> Optional[str]:
417
  """
418
  Extract existing space ID from chat history (for updates after followups/imports)
419
 
420
  Args:
421
+ history: Chat history (list of lists [[role, content], ...] or list of dicts)
422
  username: Current username (to verify ownership of imported spaces)
423
 
424
  Returns:
 
432
 
433
  # Look through history for previous deployments or imports
434
  for msg in history:
435
+ # Handle both list format [[role, content], ...] and dict format [{'role': ..., 'content': ...}, ...]
436
+ if isinstance(msg, list) and len(msg) >= 2:
437
+ role = msg[0]
438
+ content = msg[1]
439
+ elif isinstance(msg, dict):
440
+ role = msg.get('role', '')
441
+ content = msg.get('content', '')
442
+ else:
443
+ continue
444
 
445
  # Check assistant messages for deployment confirmations
446
  if role == 'assistant':