zsolnai commited on
Commit ·
be5c874
1
Parent(s): f7ff262
Fix claude v4
Browse files
app.py
CHANGED
|
@@ -64,16 +64,24 @@ def chat_with_bot(message, history):
|
|
| 64 |
do_sample=True,
|
| 65 |
top_p=0.95,
|
| 66 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
# Append to history
|
| 69 |
history.append({"role": "user", "content": message})
|
| 70 |
-
history.append({"role": "assistant", "content":
|
| 71 |
|
| 72 |
-
return history,
|
| 73 |
|
| 74 |
except Exception as e:
|
|
|
|
| 75 |
print(f"LLM Error: {e}")
|
| 76 |
-
|
|
|
|
| 77 |
history.append({"role": "user", "content": message})
|
| 78 |
history.append({"role": "assistant", "content": error_msg})
|
| 79 |
return history, error_msg
|
|
|
|
| 64 |
do_sample=True,
|
| 65 |
top_p=0.95,
|
| 66 |
)
|
| 67 |
+
|
| 68 |
+
if not response:
|
| 69 |
+
response = "I received an empty response. Please try again."
|
| 70 |
+
print("Warning: Empty response from LLM")
|
| 71 |
+
|
| 72 |
+
response_str = str(response).strip()
|
| 73 |
|
| 74 |
# Append to history
|
| 75 |
history.append({"role": "user", "content": message})
|
| 76 |
+
history.append({"role": "assistant", "content": response_str})
|
| 77 |
|
| 78 |
+
return history, response_str
|
| 79 |
|
| 80 |
except Exception as e:
|
| 81 |
+
import traceback
|
| 82 |
print(f"LLM Error: {e}")
|
| 83 |
+
print(f"Traceback: {traceback.format_exc()}")
|
| 84 |
+
error_msg = f"Error: {str(e) if str(e) else 'Unknown error occurred'}"
|
| 85 |
history.append({"role": "user", "content": message})
|
| 86 |
history.append({"role": "assistant", "content": error_msg})
|
| 87 |
return history, error_msg
|