💡 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
Delete existing file when creating new SQLite db
davidmezzetti787de6a648b1
diff --git a/src/python/txtai/database/sqlite.py b/src/python/txtai/database/sqlite.pyindex a3d3afbb..7d77b366 100644--- a/src/python/txtai/database/sqlite.py+++ b/src/python/txtai/database/sqlite.py@@ -4,6 +4,7 @@ SQLite moduleimport datetimeimport json+import osimport sqlite3from .base import Database@@ -133,6 +134,10 @@ class SQLite(Database):# If this is a temporary database, copy over to database at pathif not self.path:+ # Delete existing file, if necessary+ if os.path.exists(path):+ os.remove(path)+# Create databaseconnection = sqlite3.connect(path)diff --git a/test/python/testdatabase/testembeddings.py b/test/python/testdatabase/testembeddings.pyindex ea37b2c2..7c7d6700 100644--- a/test/python/testdatabase/testembeddings.py+++ b/test/python/testdatabase/testembeddings.py@@ -127,10 +127,14 @@ class TestEmbeddings(unittest.TestCase):# Test similarresult = self.embeddings.search(- "select * from txtai where similar('feel good story') group by text having count(*) > 0 order by score desc", 5+ "select * from txtai where similar('feel good story') group by text having count(*) > 0 order by score desc", 1)[0]self.assertEqual(result["text"], self.data[4])+ # Test similar with limits+ result = self.embeddings.search("select * from txtai where similar('feel good story', 1) limit 1")[0]+ self.assertEqual(result["text"], self.data[4])+# Test whereresult = self.embeddings.search("select * from txtai where text like '%iceberg%'", 1)[0]self.assertEqual(result["text"], self.data[1])@@ -192,7 +196,7 @@ class TestEmbeddings(unittest.TestCase):WordVectors.build(tokens, 10, 1, vectors)# Create dataset- data = [(x, row, None) for x, row in enumerate(self.data)]+ data = [(x, row.split(), None) for x, row in enumerate(self.data)]# Create embeddings model, backed by word vectorsembeddings = Embeddings(