cstr commited on
Commit
187163f
·
verified ·
1 Parent(s): 77b55d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -536,9 +536,12 @@ def prepare_message_with_media(text, images=None, documents=None):
536
  def format_to_message_dict(history):
537
  """Convert history to proper message format"""
538
  messages = []
539
- for pair in history:
540
- if len(pair) == 2:
541
- human, ai = pair
 
 
 
542
  if human:
543
  messages.append({"role": "user", "content": human})
544
  if ai:
 
536
  def format_to_message_dict(history):
537
  """Convert history to proper message format"""
538
  messages = []
539
+ for message in history:
540
+ if isinstance(message, dict) and "role" in message and "content" in message:
541
+ # Already in the correct format
542
+ messages.append(message)
543
+ elif len(message) == 2: # Handle old format [user_msg, ai_msg]
544
+ human, ai = message
545
  if human:
546
  messages.append({"role": "user", "content": human})
547
  if ai: