Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Fix bug with missing application locks, closes #305

davidmezzettie325db9fd5bb
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.py
index 5ce9d258..f71e0c3f 100644
--- a/src/python/txtai/app/base.py
+++ b/src/python/txtai/app/base.py
@@ -270,8 +270,11 @@ class Application:
"""
if self.embeddings:
+ with self.lock:
+ results = self.embeddings.search(query, limit)
+
# Unpack (id, score) tuple, if necessary. Otherwise, results are dictionaries.
- return [{"id": r[0], "score": float(r[1])} if isinstance(r, tuple) else r for r in self.embeddings.search(query, limit)]
+ return [{"id": r[0], "score": float(r[1])} if isinstance(r, tuple) else r for r in results]
return None
@@ -487,7 +490,8 @@ class Application:
"""
if self.embeddings:
- return self.embeddings.explain(query, texts, limit)
+ with self.lock:
+ return self.embeddings.explain(query, texts, limit)
return None
@@ -505,7 +509,8 @@ class Application:
"""
if self.embeddings:
- return self.embeddings.batchexplain(queries, texts, limit)
+ with self.lock:
+ return self.embeddings.batchexplain(queries, texts, limit)
return None