💡 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
Keep 0 and False in concat merge outputs
Lesereingrape6bc76132d095
diff --git a/src/python/txtai/workflow/task/base.py b/src/python/txtai/workflow/task/base.pyindex 3731db66..a6341bc0 100644--- a/src/python/txtai/workflow/task/base.py+++ b/src/python/txtai/workflow/task/base.py@@ -490,7 +490,8 @@ class Task:list of concat outputs"""- return [". ".join([str(y) for y in x if y]) for x in self.hstack(outputs)]+ # Only skip empty values: 0 and False are data, as the tabular pipeline's concat already treats them+ return [". ".join([str(y) for y in x if y is not None and y != ""]) for x in self.hstack(outputs)]class OneToMany:diff --git a/test/python/testworkflow.py b/test/python/testworkflow.pyindex baf38a83..0d754742 100644--- a/test/python/testworkflow.py+++ b/test/python/testworkflow.py@@ -344,6 +344,26 @@ class TestWorkflow(unittest.TestCase):results = list(workflow([2, 4, 6]))self.assertEqual(results, [4, 16, 36])+ def testMergeWorkflowFalsyValues(self):+ """+ Test concat merge with falsy values+ """++ # A 0 is real data, the Tabular pipeline keeps it (see #1207), concat merge should too+ task = Task([lambda x: [0, 5], lambda x: ["Widget", "Gadget"]], merge="concat")+ results = list(task([1, 2]))+ self.assertEqual(results, ["0. Widget", "5. Gadget"])++ # False is likewise real data+ task = Task([lambda x: [False, True], lambda x: ["Widget", "Gadget"]], merge="concat")+ results = list(task([1, 2]))+ self.assertEqual(results, ["False. Widget", "True. Gadget"])++ # None and empty values stay excluded, they add nothing but a separator+ task = Task([lambda x: [None, ""], lambda x: ["Widget", "Gadget"]], merge="concat")+ results = list(task([1, 2]))+ self.assertEqual(results, ["Widget", "Gadget"])+def testMergeUnbalancedWorkflow(self):"""Test merge tasks with unbalanced outputs (i.e. one action produce more output than another for same input).