Update app.py
Browse files
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 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
history.append((message, reply))
|
| 19 |
return history, history
|
| 20 |
|
| 21 |
except Exception as e:
|
| 22 |
-
|
| 23 |
-
history.append((message,
|
| 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
|