mhamoody commited on
Commit
9b6f7aa
·
verified ·
1 Parent(s): 1631ff8
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -40,11 +40,21 @@ def bot(
40
  if not google_key:
41
  raise ValueError("GOOGLE_API_KEY is not set. Please set it up.")
42
 
43
- text_prompt = chatbot[-1]["content"].strip() if chatbot[-1]["content"] else None
 
 
 
 
 
 
 
 
 
 
44
 
45
  # Handle cases for text and/or image input
46
  if not text_prompt and not image_prompt:
47
- chatbot[-1]["content"] = "Prompt cannot be empty. Please provide input text or an image."
48
  yield chatbot
49
  return
50
  elif image_prompt and not text_prompt:
 
40
  if not google_key:
41
  raise ValueError("GOOGLE_API_KEY is not set. Please set it up.")
42
 
43
+ # Extract text content from message (handle both string and list formats)
44
+ content = chatbot[-1]["content"]
45
+ if isinstance(content, list):
46
+ # In multimodal format, content is a list of items
47
+ text_prompt = None
48
+ for item in content:
49
+ if isinstance(item, str):
50
+ text_prompt = item.strip()
51
+ break
52
+ else:
53
+ text_prompt = content.strip() if content else None
54
 
55
  # Handle cases for text and/or image input
56
  if not text_prompt and not image_prompt:
57
+ chatbot[-1]["content"] = [{"type": "text", "text": "Prompt cannot be empty. Please provide input text or an image."}] if isinstance(chatbot[-1]["content"], list) else "Prompt cannot be empty. Please provide input text or an image."
58
  yield chatbot
59
  return
60
  elif image_prompt and not text_prompt: