Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,15 +129,21 @@ def add_memory():
|
|
| 129 |
return jsonify({"error": "Database could not be initialized. Check logs."}), 500
|
| 130 |
|
| 131 |
content = request.form.get('content')
|
| 132 |
-
|
|
|
|
| 133 |
if not content:
|
| 134 |
return jsonify({"error": "No content provided"}), 400
|
| 135 |
|
| 136 |
try:
|
| 137 |
-
#
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
#
|
| 141 |
if hasattr(db, 'commit'):
|
| 142 |
db.commit()
|
| 143 |
|
|
@@ -146,6 +152,8 @@ def add_memory():
|
|
| 146 |
|
| 147 |
return jsonify({"success": True, "message": "Memory added and synced to cloud."})
|
| 148 |
except Exception as e:
|
|
|
|
|
|
|
| 149 |
return jsonify({"error": str(e)}), 500
|
| 150 |
|
| 151 |
@app.route('/search', methods=['POST'])
|
|
|
|
| 129 |
return jsonify({"error": "Database could not be initialized. Check logs."}), 500
|
| 130 |
|
| 131 |
content = request.form.get('content')
|
| 132 |
+
tags = request.form.get('tags', '') # Can be passed as comma-separated string
|
| 133 |
+
|
| 134 |
if not content:
|
| 135 |
return jsonify({"error": "No content provided"}), 400
|
| 136 |
|
| 137 |
try:
|
| 138 |
+
# FIX: Use keyword argument 'text'
|
| 139 |
+
# The SDK supports: .put(text="...") OR .put(file="path/to.pdf")
|
| 140 |
+
# It likely accepts 'tags' or 'metadata' as well
|
| 141 |
+
db.put(text=content)
|
| 142 |
+
|
| 143 |
+
# If the SDK supports tags, it typically looks like this:
|
| 144 |
+
# db.put(text=content, tags=tags)
|
| 145 |
|
| 146 |
+
# Check for explicit commit if needed
|
| 147 |
if hasattr(db, 'commit'):
|
| 148 |
db.commit()
|
| 149 |
|
|
|
|
| 152 |
|
| 153 |
return jsonify({"success": True, "message": "Memory added and synced to cloud."})
|
| 154 |
except Exception as e:
|
| 155 |
+
# Print error to logs for easier debugging
|
| 156 |
+
print(f"Error adding memory: {e}")
|
| 157 |
return jsonify({"error": str(e)}), 500
|
| 158 |
|
| 159 |
@app.route('/search', methods=['POST'])
|