💡 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
Write RDBMS graph attribute changes to the database
kartsan0304f5bf1998a7
diff --git a/src/python/txtai/graph/rdbms.py b/src/python/txtai/graph/rdbms.pyindex 5397dc4e..ac8c3f22 100644--- a/src/python/txtai/graph/rdbms.py+++ b/src/python/txtai/graph/rdbms.py@@ -59,6 +59,10 @@ class RDBMS(NetworkX):else:yield from super().scan(attribute, data)+ def addattribute(self, node, field, value):+ if self.hasnode(node):+ self.graph.backend.add_node(node, {field: value})+def load(self, path):# Create graph instanceself.graph, self.database = self.connect()diff --git a/test/python/testgraph.py b/test/python/testgraph.pyindex 934b6b80..aebae332 100644--- a/test/python/testgraph.py+++ b/test/python/testgraph.py@@ -173,10 +173,16 @@ class TestGraph(unittest.TestCase):self.assertEqual(list(graph.scan(attribute="field")), [str(x) for x in range(5)])self.assertEqual(list(graph.filter([0]).scan()), [0])+ # Attribute changes must be written through to the database+ graph.addattribute(0, "field", "updated")+ graph.addattribute(0, "label", "new")+# Test save/loadgraph.save(None)graph.load(None)self.assertEqual(list(graph.scan()), [str(x) for x in range(5)])+ self.assertEqual(graph.node(0), {"field": "updated", "label": "new"})+ self.assertEqual(graph.edgecount(), 10)# Test remove nodegraph.delete([0])