Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Ensure extractor input queue is not empty, closes #456

davidmezzettia82e88991d08
diff --git a/src/python/txtai/pipeline/text/extractor.py b/src/python/txtai/pipeline/text/extractor.py
index 1dabaf56..27921350 100644
--- a/src/python/txtai/pipeline/text/extractor.py
+++ b/src/python/txtai/pipeline/text/extractor.py
@@ -90,7 +90,7 @@ class Extractor(Pipeline):
inputs = queue
# Convert dictionary inputs to tuples
- if isinstance(queue[0], dict):
+ if queue and isinstance(queue[0], dict):
# Convert dict to tuple
queue = [tuple(row.get(x) for x in ["name", "query", "question", "snippet"]) for row in queue]
@@ -366,7 +366,7 @@ class Extractor(Pipeline):
answers = self.reference(queries, answers, topns)
# Ensure output format matches input format
- if isinstance(inputs[0], dict):
+ if inputs and isinstance(inputs[0], dict):
# Add name if input queue had name field
fields = ["name", "answer", "reference"] if "name" in inputs[0] else [None, "answer", "reference"]
answers = [{fields[x]: column for x, column in enumerate(row) if fields[x]} for row in answers]