💡 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
Allow all supported pipeline config via API. Default to smaller models for labels to work with GitHub Actions.
davidmezzetti79aae2d31f63
diff --git a/src/python/txtai/api.py b/src/python/txtai/api.pyindex 88303b6e..958e1842 100644--- a/src/python/txtai/api.py+++ b/src/python/txtai/api.py@@ -48,11 +48,14 @@ class API(object):# Extractor settingsextractor = self.config["extractor"]- self.extractor = Extractor(self.embeddings, extractor["path"], extractor.get("quantize"))+ self.extractor = Extractor(self.embeddings, extractor.get("path"), extractor.get("quantize"),+ extractor.get("gpu"))# Create labels instanceif "labels" in self.config:- self.labels = Labels()+ labels = self.config["labels"]++ self.labels = Labels(labels.get("path"), labels.get("quantize"), labels.get("gpu"))def size(self, request):"""diff --git a/src/python/txtai/pipeline.py b/src/python/txtai/pipeline.pyindex d80062f8..d57d677a 100644--- a/src/python/txtai/pipeline.py+++ b/src/python/txtai/pipeline.py@@ -8,7 +8,7 @@ from transformers import pipelineclass Pipeline(object):"""- Light wrapper around HuggingFace's pipeline component for selected tasks. Adds support for model+ Light wrapper around Hugging Face's pipeline component for selected tasks. Adds support for modelquantization and minor interface changes."""@@ -18,7 +18,8 @@ class Pipeline(object):Args:task: pipeline task or category- path: optional path to model, will use default model for task if not provided+ path: optional path to model, accepts Hugging Face model hub id or local path,+ uses default model for task if not providedquantize: if model should be quantized, defaults to Falsegpu: if gpu inference should be used (only works if GPUs are available)"""diff --git a/test/python/testapi.py b/test/python/testapi.pyindex 31073f0f..97f13062 100644--- a/test/python/testapi.py+++ b/test/python/testapi.py@@ -33,6 +33,7 @@ extractor:# Labels settingslabels:+ path: squeezebert/squeezebert-mnli"""# Configuration that reads an existing similarity search indexdiff --git a/test/python/testlabels.py b/test/python/testlabels.pyindex 5df843fc..d5f15155 100644--- a/test/python/testlabels.py+++ b/test/python/testlabels.py@@ -16,5 +16,5 @@ class TestLabels(unittest.TestCase):Test labels"""- labels = Labels()+ labels = Labels("squeezebert/squeezebert-mnli")self.assertEqual(labels("This is the best sentence ever", ["positive", "negative"])[0][0], "positive")