Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Support graph=True in embeddings config, closes #848

davidmezzettic7e0fe3f999b
diff --git a/src/python/txtai/embeddings/base.py b/src/python/txtai/embeddings/base.py
index f9b65122..268cd8e0 100644
--- a/src/python/txtai/embeddings/base.py
+++ b/src/python/txtai/embeddings/base.py
@@ -821,6 +821,10 @@ class Embeddings:
if not self.config.get("scoring") and any(self.config.get(key) for key in ["keyword", "hybrid"]):
self.config["scoring"] = {"method": "bm25", "terms": True, "normalize": True}
+ # Expand graph shortcuts
+ if self.config.get("graph") is True:
+ self.config["graph"] = {}
+
# Check if default model should be loaded
if not self.model and self.defaultallowed():
self.config["path"] = "sentence-transformers/all-MiniLM-L6-v2"
diff --git a/test/python/testgraph.py b/test/python/testgraph.py
index e5c7e03d..1cd645e7 100644
--- a/test/python/testgraph.py
+++ b/test/python/testgraph.py
@@ -146,6 +146,16 @@ class TestGraph(unittest.TestCase):
# Close graph
graph.close()
+ def testDefault(self):
+ """
+ Test embeddings default graph setting
+ """
+
+ embeddings = Embeddings(content=True, graph=True)
+ embeddings.index([(uid, text, None) for uid, text in enumerate(self.data)])
+
+ self.assertEqual(embeddings.graph.count(), len(self.data))
+
def testDelete(self):
"""
Test delete