Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Add ability for extractor to reference another pipeline in applications, closes #501

davidmezzetti97401266228c
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.py
index 437f09c7..dfe4be63 100644
--- a/src/python/txtai/app/base.py
+++ b/src/python/txtai/app/base.py
@@ -102,6 +102,9 @@ class Application:
if "." in key:
pipelines.append(key)
+ # Move dependent pipelines to end of list
+ pipelines = sorted(pipelines, key=lambda x: x in ["similarity", "extractor"])
+
# Create pipelines
for pipeline in pipelines:
if pipeline in self.config:
@@ -115,6 +118,11 @@ class Application:
if pipeline == "extractor" and "similarity" not in config:
# Add placeholder, will be set to embeddings index once initialized
config["similarity"] = None
+
+ # Resolve reference pipeline, if necessary
+ if config.get("path") in self.pipelines:
+ config["path"] = self.pipelines[config["path"]]
+
elif pipeline == "similarity" and "path" not in config and "labels" in self.pipelines:
config["model"] = self.pipelines["labels"]
diff --git a/test/python/testapi/testembeddings.py b/test/python/testapi/testembeddings.py
index 65665515..90e31491 100644
--- a/test/python/testapi/testembeddings.py
+++ b/test/python/testapi/testembeddings.py
@@ -21,13 +21,17 @@ path: %s
# Allow indexing of documents
writable: True
+# Questions settings
+questions:
+ path: distilbert-base-cased-distilled-squad
+
# Embeddings settings
embeddings:
path: sentence-transformers/nli-mpnet-base-v2
# Extractor settings
extractor:
- path: distilbert-base-cased-distilled-squad
+ path: questions
"""
# Configuration for a read-only embeddings index