Spaces:
Build error
Build error
Commit ·
4587c91
1
Parent(s): 04043b8
fix db
Browse files- src/feedback_handler.py +9 -3
src/feedback_handler.py
CHANGED
|
@@ -17,13 +17,19 @@ def init_mongodb():
|
|
| 17 |
try:
|
| 18 |
client = MongoClient(MONGODB_URI, serverSelectionTimeoutMS=5000)
|
| 19 |
client.server_info()
|
| 20 |
-
return client
|
| 21 |
except Exception as e:
|
| 22 |
error_msg = f"⚠️ Failed connecting to database: {str(e)}"
|
| 23 |
return error_msg
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
FEEDBACK_KEYWORDS = ['Feedback', 'feedback', 'Feedback', 'Feedback?', 'feedback?', 'feedback!', 'not helpful', 'not helpful', 'not helpful?', 'not helpful?', 'not helpful!', 'helpful', 'helpful?', 'helpful!', "'helpful'", "'not helpful", "'feedback'"]
|
| 29 |
|
|
|
|
| 17 |
try:
|
| 18 |
client = MongoClient(MONGODB_URI, serverSelectionTimeoutMS=5000)
|
| 19 |
client.server_info()
|
| 20 |
+
return client
|
| 21 |
except Exception as e:
|
| 22 |
error_msg = f"⚠️ Failed connecting to database: {str(e)}"
|
| 23 |
return error_msg
|
| 24 |
|
| 25 |
+
client = init_mongodb()
|
| 26 |
+
if client:
|
| 27 |
+
db = client['instant_bot']
|
| 28 |
+
collection = db['instant']
|
| 29 |
+
feedback_collection = db['feedback']
|
| 30 |
+
else:
|
| 31 |
+
collection = None
|
| 32 |
+
feedback_collection = None
|
| 33 |
|
| 34 |
FEEDBACK_KEYWORDS = ['Feedback', 'feedback', 'Feedback', 'Feedback?', 'feedback?', 'feedback!', 'not helpful', 'not helpful', 'not helpful?', 'not helpful?', 'not helpful!', 'helpful', 'helpful?', 'helpful!', "'helpful'", "'not helpful", "'feedback'"]
|
| 35 |
|