hamada056 commited on
Commit
23c0207
·
verified ·
1 Parent(s): bd5a001

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -44,7 +44,14 @@ def bot(
44
  if not google_key:
45
  raise ValueError("GOOGLE_API_KEY is not set. Please set it up.")
46
 
47
- text_prompt = chatbot[-2]["content"].strip() if len(chatbot) >= 2 and chatbot[-2]["content"] else None
 
 
 
 
 
 
 
48
 
49
  # Handle cases for text and/or image input
50
  if not text_prompt and not image_prompt:
@@ -76,6 +83,7 @@ def bot(
76
  yield chatbot
77
  return
78
 
 
79
  chatbot[-1]["content"] = ""
80
  for chunk in response:
81
  for i in range(0, len(chunk.text), 10):
 
44
  if not google_key:
45
  raise ValueError("GOOGLE_API_KEY is not set. Please set it up.")
46
 
47
+ raw_content = chatbot[-2]["content"] if len(chatbot) >= 2 else None
48
+
49
+ if isinstance(raw_content, list):
50
+ text_prompt = " ".join(str(item) for item in raw_content)
51
+ else:
52
+ text_prompt = raw_content
53
+
54
+ text_prompt = text_prompt.strip() if text_prompt else None
55
 
56
  # Handle cases for text and/or image input
57
  if not text_prompt and not image_prompt:
 
83
  yield chatbot
84
  return
85
 
86
+ # Stream the response
87
  chatbot[-1]["content"] = ""
88
  for chunk in response:
89
  for i in range(0, len(chunk.text), 10):