💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Switch SQLite ANN connections when load() is given a new path
kartsan03fe1fbbc933d2
diff --git a/src/python/txtai/ann/dense/sqlite.py b/src/python/txtai/ann/dense/sqlite.pyindex 1ced45be..5f6970a3 100644--- a/src/python/txtai/ann/dense/sqlite.py+++ b/src/python/txtai/ann/dense/sqlite.py@@ -35,6 +35,8 @@ class SQLite(ANN):self.quantize = 8 if isinstance(self.quantize, bool) and self.quantize else int(self.quantize) if self.quantize else Nonedef load(self, path):+ if self.path != path:+ self.close()self.path = pathdef index(self, embeddings):diff --git a/test/python/testann/testdense/testsqlite.py b/test/python/testann/testdense/testsqlite.pyindex 756ee869..5ee29121 100644--- a/test/python/testann/testdense/testsqlite.py+++ b/test/python/testann/testdense/testsqlite.py@@ -140,6 +140,8 @@ class TestSQLite(DenseTest):# Load new copy and check that it has all the changesmodel = ANNFactory.create(model.config)+ model.load(index)+ self.assertEqual(model.count(), 500)model.load(new)self.assertEqual(model.count(), 509)self.assertEqual(len(model.search(np.random.rand(1, 240).astype(np.float32), 10)[0]), 10)