💡 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
Skip PGText insert when a batch has no text rows (#1447)
Muneeb Ullahacf38592e1d8
diff --git a/src/python/txtai/scoring/pgtext.py b/src/python/txtai/scoring/pgtext.pyindex 840f526e..95414955 100644--- a/src/python/txtai/scoring/pgtext.py+++ b/src/python/txtai/scoring/pgtext.py@@ -62,7 +62,8 @@ class PGText(Scoring):index = index + 1 if index is not None else None# Insert rows- self.database.execute(self.table.insert(), [{"indexid": x, "text": text} for x, text in rows])+ if rows:+ self.database.execute(self.table.insert(), [{"indexid": x, "text": text} for x, text in rows])def delete(self, ids):self.database.execute(delete(self.table).where(self.table.c["indexid"].in_(ids)))diff --git a/test/python/testscoring/testkeyword.py b/test/python/testscoring/testkeyword.pyindex 8eb6c405..c5c036af 100644--- a/test/python/testscoring/testkeyword.py+++ b/test/python/testscoring/testkeyword.py@@ -267,6 +267,22 @@ class TestKeyword(unittest.TestCase):# Close scoringscoring.close()+ def testPGTextEmpty(self):+ """+ Test PGText with a batch that has no text rows+ """++ # Create scoring+ path = os.path.join(tempfile.gettempdir(), "pgtext.sqlite")+ scoring = ScoringFactory.create({"method": "pgtext", "url": f"sqlite:///{path}", "schema": "txtai"})+ scoring.index([(0, None, None), (1, 5, None)])++ # No phantom row should be inserted+ self.assertEqual(scoring.count(), 0)++ # Close scoring+ scoring.close()+def testSIF(self):"""Test sif