💡 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
Add ability to resolve workflows within applications, closes #290
davidmezzetti917b2cfe59ee
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.pyindex b4e01786..5ce9d258 100644--- a/src/python/txtai/app/base.py+++ b/src/python/txtai/app/base.py@@ -242,9 +242,14 @@ class Application:resolved function"""+ # Check if function is a pipelineif function in self.pipelines:return self.pipelines[function]+ # Check if function is a workflow+ if function in self.workflows:+ return self.workflows[function]+# Attempt to resolve action as a callable functionreturn PipelineFactory.create({}, function)diff --git a/test/python/testworkflow.py b/test/python/testworkflow.pyindex f8b5a315..48eeffaa 100644--- a/test/python/testworkflow.py+++ b/test/python/testworkflow.py@@ -477,6 +477,30 @@ class TestWorkflow(unittest.TestCase):"And another sentence to split.",)+ def testYamlWorkflowTask(self):+ """+ Tests YAML workflow with a workflow task+ """++ # Create function and add to module+ def action(elements):+ return [x * 2 for x in elements]++ sys.modules[__name__].action = action++ workflow = """+ workflow:+ run:+ tasks:+ - testworkflow.action+ flow:+ tasks:+ - run+ """++ app = API(workflow)+ self.assertEqual(list(app.workflow("flow", [1, 2])), [2, 4])+def testYamlTransformWorkflow(self):"""Test reading a YAML transform workflow in Python.