Anmol3263 commited on
Commit
97b5d5f
·
verified ·
1 Parent(s): 95721d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -10,17 +10,25 @@ model = genai.GenerativeModel("gemini-pro")
10
 
11
  def chat(message, history):
12
  try:
 
 
13
  response = model.generate_content(message)
 
 
 
14
 
15
- # Safe response handling
16
- reply = response.text if hasattr(response, "text") else str(response)
 
 
 
17
 
18
  history.append((message, reply))
19
  return history, history
20
 
21
  except Exception as e:
22
- error_msg = f"Error: {str(e)}"
23
- history.append((message, error_msg))
24
  return history, history
25
 
26
  # Gradio UI
 
10
 
11
  def chat(message, history):
12
  try:
13
+ print("Incoming message:", message)
14
+
15
  response = model.generate_content(message)
16
+ print("Raw response:", response)
17
+
18
+ reply = ""
19
 
20
+ try:
21
+ reply = response.text
22
+ except Exception as e:
23
+ print("TEXT ERROR:", e)
24
+ reply = str(response)
25
 
26
  history.append((message, reply))
27
  return history, history
28
 
29
  except Exception as e:
30
+ print("FULL ERROR:", e)
31
+ history.append((message, f"Error: {str(e)}"))
32
  return history, history
33
 
34
  # Gradio UI