💡 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
Make faiss a required library for all platforms (#98)
davidmezzettib90b2f4460c8
diff --git a/src/python/txtai/ann/factory.py b/src/python/txtai/ann/factory.pyindex 8f84ea70..6767b4d7 100644--- a/src/python/txtai/ann/factory.py+++ b/src/python/txtai/ann/factory.py@@ -3,7 +3,7 @@ Factory module"""from .annoy import Annoy, ANNOY-from .faiss import Faiss, FAISS+from .faiss import Faissfrom .hnsw import HNSW, HNSWLIB@@ -26,11 +26,7 @@ class ANNFactory:# ANN modelmodel = None- backend = config.get("backend")-- # Default backend if not provided, based on available libraries- if not backend:- backend = "faiss" if FAISS else "hnsw"+ backend = config.get("backend", "faiss")# Create ANN instanceif backend == "annoy":@@ -44,9 +40,6 @@ class ANNFactory:model = HNSW(config)else:- if not FAISS:- raise ImportError("Faiss library is not available for this platform")-model = Faiss(config)# Store config backdiff --git a/src/python/txtai/ann/faiss.py b/src/python/txtai/ann/faiss.pyindex 72f891fd..677e16c9 100644--- a/src/python/txtai/ann/faiss.py+++ b/src/python/txtai/ann/faiss.py@@ -4,15 +4,9 @@ Faiss moduleimport numpy as np-from .base import ANN--# Conditional import-try:- from faiss import index_factory, METRIC_INNER_PRODUCT, read_index, write_index+from faiss import index_factory, METRIC_INNER_PRODUCT, read_index, write_index- FAISS = True-except ImportError:- FAISS = False+from .base import ANNclass Faiss(ANN):diff --git a/test/python/testoptional.py b/test/python/testoptional.pyindex 0c198523..776bb6f3 100644--- a/test/python/testoptional.py+++ b/test/python/testoptional.py@@ -25,7 +25,6 @@ class TestOptional(unittest.TestCase):"""txtai.ann.factory.ANNOY = not txtai.ann.factory.ANNOY- txtai.ann.factory.FAISS = not txtai.ann.factory.FAISStxtai.ann.factory.HNSWLIB = not txtai.ann.factory.HNSWLIBtxtai.pipeline.segmentation.NLTK = not txtai.pipeline.segmentation.NLTK@@ -65,10 +64,6 @@ class TestOptional(unittest.TestCase):with self.assertRaises(ImportError):ANNFactory.create({"backend": "annoy"})- if not txtai.ann.factory.FAISS:- with self.assertRaises(ImportError):- ANNFactory.create({"backend": "faiss"})-with self.assertRaises(ImportError):ANNFactory.create({"backend": "hnsw"})