akhaliq HF Staff commited on
Commit
f9c99cb
·
verified ·
1 Parent(s): 3e30851

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -28,12 +28,9 @@ def generate_response(message, history, thinking_mode):
28
  if isinstance(user_msg, str):
29
  user_content = [{"type": "text", "text": user_msg}]
30
  else:
31
- if isinstance(user_msg, tuple):
32
- text, file_paths = user_msg
33
- else:
34
- text = user_msg.get('text', '')
35
- files = user_msg.get('files', [])
36
- file_paths = [f['path'] if isinstance(f, dict) else f for f in files]
37
  user_content = []
38
  img_paths = file_paths if isinstance(file_paths, list) else []
39
  for path in img_paths:
@@ -54,13 +51,13 @@ def generate_response(message, history, thinking_mode):
54
  # Current user message
55
  if isinstance(message, str):
56
  curr_text = message
57
- curr_file_paths = []
58
  else:
59
  curr_text = message.get('text', '')
60
  curr_files = message.get('files', [])
61
- curr_file_paths = [f['path'] if isinstance(f, dict) else f for f in curr_files]
62
  curr_user_content = []
63
  curr_images = []
 
64
  for path in curr_file_paths:
65
  if path.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp')):
66
  try:
@@ -109,7 +106,7 @@ def generate_response(message, history, thinking_mode):
109
  )
110
 
111
  # Prepare display for current user message
112
- user_display = curr_text if not curr_file_paths else (curr_text, curr_file_paths)
113
  new_history = history + [(user_display, output_text)]
114
 
115
  return "", new_history
 
28
  if isinstance(user_msg, str):
29
  user_content = [{"type": "text", "text": user_msg}]
30
  else:
31
+ text = user_msg.get('text', '')
32
+ files = user_msg.get('files', [])
33
+ file_paths = [f.get('path', str(f)) for f in files]
 
 
 
34
  user_content = []
35
  img_paths = file_paths if isinstance(file_paths, list) else []
36
  for path in img_paths:
 
51
  # Current user message
52
  if isinstance(message, str):
53
  curr_text = message
54
+ curr_files = []
55
  else:
56
  curr_text = message.get('text', '')
57
  curr_files = message.get('files', [])
 
58
  curr_user_content = []
59
  curr_images = []
60
+ curr_file_paths = [f.get('path', str(f)) for f in curr_files]
61
  for path in curr_file_paths:
62
  if path.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp')):
63
  try:
 
106
  )
107
 
108
  # Prepare display for current user message
109
+ user_display = message
110
  new_history = history + [(user_display, output_text)]
111
 
112
  return "", new_history