Vladyslav Humennyy Claude commited on
Commit
6587188
·
1 Parent(s): e6d0602

Add alt_text field to image content for Gradio validation

Browse files

Gradio requires alt_text to be a string when present, so explicitly set it to "uploaded image" when creating image content.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -98,7 +98,7 @@ def user(user_message, image_data, history: list):
98
  "role": "user",
99
  "content": [
100
  {"type": "text", "text": stripped_message},
101
- {"type": "image", "path": tmp_path, "_pil_image": image_obj}
102
  ]
103
  })
104
  has_content = True
@@ -108,7 +108,7 @@ def user(user_message, image_data, history: list):
108
  elif tmp_path is not None:
109
  updated_history.append({
110
  "role": "user",
111
- "content": [{"type": "image", "path": tmp_path, "_pil_image": image_obj}]
112
  })
113
  has_content = True
114
 
 
98
  "role": "user",
99
  "content": [
100
  {"type": "text", "text": stripped_message},
101
+ {"type": "image", "path": tmp_path, "alt_text": "uploaded image", "_pil_image": image_obj}
102
  ]
103
  })
104
  has_content = True
 
108
  elif tmp_path is not None:
109
  updated_history.append({
110
  "role": "user",
111
+ "content": [{"type": "image", "path": tmp_path, "alt_text": "uploaded image", "_pil_image": image_obj}]
112
  })
113
  has_content = True
114