mirror of
https://github.com/SillyTavern/SillyTavern-Extras.git
synced 2026-04-30 03:11:26 +00:00
Add chromadb purge method
This commit is contained in:
17
server.py
17
server.py
@@ -695,6 +695,23 @@ def chromadb_add_messages():
|
||||
return jsonify({"count": len(ids)})
|
||||
|
||||
|
||||
@app.route("/api/chromadb/purge", methods=["POST"])
|
||||
@require_module("chromadb")
|
||||
def chromadb_purge():
|
||||
data = request.get_json()
|
||||
if "chat_id" not in data or not isinstance(data["chat_id"], str):
|
||||
abort(400, '"chat_id" is required')
|
||||
|
||||
chat_id_md5 = hashlib.md5(data["chat_id"].encode()).hexdigest()
|
||||
collection = chromadb_client.get_or_create_collection(
|
||||
name=f"chat-{chat_id_md5}", embedding_function=chromadb_embed_fn
|
||||
)
|
||||
|
||||
deleted = collection.delete()
|
||||
print("ChromaDB embeddings deleted", len(deleted))
|
||||
return 'Ok', 200
|
||||
|
||||
|
||||
@app.route("/api/chromadb/query", methods=["POST"])
|
||||
@require_module("chromadb")
|
||||
def chromadb_query():
|
||||
|
||||
Reference in New Issue
Block a user