diff --git a/rag/nlp/search.py b/rag/nlp/search.py index e2128a26..187c2030 100644 --- a/rag/nlp/search.py +++ b/rag/nlp/search.py @@ -363,7 +363,6 @@ class Dealer: sres = self.search(req, [index_name(tid) for tid in tenant_ids], kb_ids, embd_mdl, highlight, rank_feature=rank_feature) - ranks["total"] = sres.total if rerank_mdl and sres.total > 0: sim, tsim, vsim = self.rerank_by_model(rerank_mdl, @@ -383,6 +382,9 @@ class Dealer: if doc_ids: similarity_threshold = 0 page_size = 30 + sim_np = np.array(sim) + filtered_count = (sim_np >= similarity_threshold).sum() + ranks["total"] = int(filtered_count) # Convert from np.int64 to Python int otherwise JSON serializable error for i in idx: if sim[i] < similarity_threshold: break