broadfield-dev commited on
Commit
42d0d21
·
verified ·
1 Parent(s): 1cb329a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  from flask import Flask, render_template, request, jsonify
3
- # Keeping your working imports
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: Pass a Dictionary with a 'text' key.
134
- # This solves "unexpected keyword argument 'text'" (from db.put(text=...))
135
- # AND "str cannot be converted to PyDict" (from db.put("string"))
136
  payload = {
137
  "text": content,
138
- "title": "User Memory",
139
- "tag": "web-entry"
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: Pass string as positional arg, top_k as keyword.
166
- # This solves "dict cannot be converted to PyString"
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 = []