Add deterministic setting to database functions closes #1048. Add ability to index database expressions #1049

This commit is contained in:
davidmezzetti
2026-02-22 16:38:54 -05:00
parent 2f2bd50027
commit 3073589ad6
8 changed files with 87 additions and 20 deletions
+16
View File
@@ -247,6 +247,22 @@ class Common:
self.assertEqual(self.embeddings.explain("select * from txtai limit 1")[0]["id"], "0")
def testExpressions(self):
"""
Test expressions
"""
# Test indexed expressions
embeddings = Embeddings(
path="sentence-transformers/nli-mpnet-base-v2",
content=self.backend,
expressions=[{"name": "textlength", "expression": "length(text)", "index": True}],
)
embeddings.index(self.data)
result = embeddings.search("SELECT textlength FROM txtai WHERE id = 0", 1)[0]
self.assertEqual(result["textlength"], len(self.data[0]))
def testGenerator(self):
"""
Test index with a generator