💡 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
Cleanup vectors package, closes #802
davidmezzetti79675f5228a1
diff --git a/src/python/txtai/vectors/factory.py b/src/python/txtai/vectors/factory.pyindex de07575b..7abdd875 100644--- a/src/python/txtai/vectors/factory.py+++ b/src/python/txtai/vectors/factory.py@@ -8,7 +8,7 @@ from .external import Externalfrom .huggingface import HFVectorsfrom .litellm import LiteLLMfrom .llama import LlamaCpp-from .words import WordVectors, WORDS+from .words import WordVectorsclass VectorsFactory:@@ -47,13 +47,6 @@ class VectorsFactory:# Word vectorsif method == "words":- if not WORDS:- # Raise error if trying to create Word Vectors without vectors extra- raise ImportError(- 'Word vector models are not available - install "vectors" extra to enable. Otherwise, specify '- + 'method="transformers" to use transformer backed models'- )-return WordVectors(config, scoring, models)# Transformers vectorsdiff --git a/src/python/txtai/vectors/litellm.py b/src/python/txtai/vectors/litellm.pyindex d7d414d2..e1ecbe39 100644--- a/src/python/txtai/vectors/litellm.py+++ b/src/python/txtai/vectors/litellm.py@@ -48,11 +48,12 @@ class LiteLLM(Vectors):return Falsedef __init__(self, config, scoring, models):- super().__init__(config, scoring, models)-+ # Check before parent constructor since it calls loadmodelif not LITELLM:raise ImportError('LiteLLM is not available - install "vectors" extra to enable')+ super().__init__(config, scoring, models)+def loadmodel(self, path):return Nonediff --git a/src/python/txtai/vectors/words.py b/src/python/txtai/vectors/words.pyindex d9751490..46f5d9ed 100644--- a/src/python/txtai/vectors/words.py+++ b/src/python/txtai/vectors/words.py@@ -66,6 +66,17 @@ class WordVectors(Vectors):Builds vectors using weighted word embeddings."""+ def __init__(self, config, scoring, models):+ # Check before parent constructor since it calls loadmodel+ if not WORDS:+ # Raise error if trying to create Word Vectors without vectors extra+ raise ImportError(+ 'Word vector models are not available - install "vectors" extra to enable. Otherwise, specify '+ + 'method="transformers" to use transformer backed models'+ )++ super().__init__(config, scoring, models)+def loadmodel(self, path):# Ensure that vector path existsif not path or not os.path.isfile(path):