Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Upgrade to Faiss 1.6.4, closes #36

davidmezzetti8801c87c020b
diff --git a/setup.py b/setup.py
index 210f4c11..7c5213e5 100644
--- a/setup.py
+++ b/setup.py
@@ -23,8 +23,7 @@ setup(name="txtai",
python_requires=">=3.6",
install_requires=[
"annoy>=1.16.3",
- "faiss-cpu>=1.6.4; sys_platform != 'darwin'",
- "faiss-cpu==1.6.4; sys_platform == 'darwin'",
+ "faiss-cpu>=1.6.4",
"fastapi>=0.61.1",
"fasttext>=0.9.2",
"hnswlib>=0.4.0",
diff --git a/src/python/txtai/ann.py b/src/python/txtai/ann.py
index b90dbde4..c0bdab61 100644
--- a/src/python/txtai/ann.py
+++ b/src/python/txtai/ann.py
@@ -4,18 +4,12 @@ ANN (Approximate Nearest Neighbors) module
import numpy as np
+import faiss
+
# pylint: disable=E0611
from annoy import AnnoyIndex
from hnswlib import Index
-# Conditionally import Faiss as it's only supported on Linux/macOS
-try:
- import faiss
- FAISS = True
-except ImportError as e:
- FAISS = False
- print(e)
-
class ANN(object):
"""
Base class for ANN models.
@@ -37,9 +31,9 @@ class ANN(object):
model = None
backend = config.get("backend")
- # Default backend if not provided, based on available libraries
+ # Default backend if not provided
if not backend:
- backend = "faiss" if FAISS else "annoy"
+ backend = "faiss"
# Create ANN instance
if backend == "annoy":
@@ -47,10 +41,6 @@ class ANN(object):
elif backend == "hnsw":
model = HNSW(config)
else:
- # Raise error if trying to create a Faiss index without Faiss installed
- if not FAISS:
- raise ImportError("Faiss library is not installed")
-
model = Faiss(config)
# Store config back