Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
from flask import Flask, render_template, request, jsonify
|
| 3 |
-
#
|
| 4 |
from memvid_sdk import create, open as open_memvid
|
| 5 |
from huggingface_hub import hf_hub_download, upload_file, HfApi
|
| 6 |
|
|
@@ -130,14 +130,14 @@ def add_memory():
|
|
| 130 |
return jsonify({"error": "No content provided"}), 400
|
| 131 |
|
| 132 |
try:
|
| 133 |
-
# FIX:
|
| 134 |
-
#
|
| 135 |
-
# AND "str cannot be converted to PyDict" (from db.put("string"))
|
| 136 |
payload = {
|
| 137 |
"text": content,
|
| 138 |
-
"
|
| 139 |
-
"
|
| 140 |
}
|
|
|
|
| 141 |
db.put(payload)
|
| 142 |
|
| 143 |
# Force flush by deleting reference (Rust Drop trait)
|
|
@@ -162,8 +162,8 @@ def search_memory():
|
|
| 162 |
return jsonify({"error": "No query provided"}), 400
|
| 163 |
|
| 164 |
try:
|
| 165 |
-
# FIX:
|
| 166 |
-
#
|
| 167 |
results = db.find(query, top_k=5)
|
| 168 |
|
| 169 |
formatted_results = []
|
|
|
|
| 1 |
import os
|
| 2 |
from flask import Flask, render_template, request, jsonify
|
| 3 |
+
# Using the imports and init logic you confirmed works
|
| 4 |
from memvid_sdk import create, open as open_memvid
|
| 5 |
from huggingface_hub import hf_hub_download, upload_file, HfApi
|
| 6 |
|
|
|
|
| 130 |
return jsonify({"error": "No content provided"}), 400
|
| 131 |
|
| 132 |
try:
|
| 133 |
+
# FIX: The error "requires either 'label' or 'labels'" implies
|
| 134 |
+
# the dict must contain both the text AND a label field.
|
|
|
|
| 135 |
payload = {
|
| 136 |
"text": content,
|
| 137 |
+
"labels": ["web-entry"], # Required by the validation logic
|
| 138 |
+
"title": "User Memory"
|
| 139 |
}
|
| 140 |
+
|
| 141 |
db.put(payload)
|
| 142 |
|
| 143 |
# Force flush by deleting reference (Rust Drop trait)
|
|
|
|
| 162 |
return jsonify({"error": "No query provided"}), 400
|
| 163 |
|
| 164 |
try:
|
| 165 |
+
# FIX: "dict cannot be converted to PyString" means
|
| 166 |
+
# the first argument must be the query string, not a dict.
|
| 167 |
results = db.find(query, top_k=5)
|
| 168 |
|
| 169 |
formatted_results = []
|