Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Consume generator outputs in workflow tasks, closes #291

davidmezzetti67b776ca437f
diff --git a/src/python/txtai/workflow/task/base.py b/src/python/txtai/workflow/task/base.py
index 1caec5f2..8558c0f6 100644
--- a/src/python/txtai/workflow/task/base.py
+++ b/src/python/txtai/workflow/task/base.py
@@ -3,6 +3,7 @@ Task module
"""
import re
+import types
import numpy as np
import torch
@@ -314,7 +315,13 @@ class Task:
"""
# Execute action and get outputs
- return action(inputs)
+ outputs = action(inputs)
+
+ # Consume generator output, if necessary
+ if isinstance(outputs, types.GeneratorType):
+ outputs = list(outputs)
+
+ return outputs
def postprocess(self, outputs):
"""