💡 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
Raise error when API task action not found. Fix scoring key reference.
davidmezzetti709937dfee0d
diff --git a/src/python/txtai/api/base.py b/src/python/txtai/api/base.pyindex 04340829..5b2a9e7b 100644--- a/src/python/txtai/api/base.py+++ b/src/python/txtai/api/base.py@@ -164,20 +164,20 @@ class API:def function(self, function):"""- Get a handle to a callable function+ Get a handle to a callable function.++ Args:+ function: function name++ Returns:+ resolved function"""if function in self.pipelines:return self.pipelines[function]- # pylint: disable=W0702- try:- # Attempt to resolve action as a callable function- return PipelineFactory.create({}, function)- except:- pass-- return None+ # Attempt to resolve action as a callable function+ return PipelineFactory.create({}, function)def limit(self, limit):"""@@ -301,7 +301,7 @@ class API:elif self.embeddings and self.config.get("writable") and self.documents:with self.lock:# Build scoring index if scoring method provided- if self.config.get("scoring"):+ if self.embeddings.scoring:self.embeddings.score(self.documents)# Build embeddings indexdiff --git a/test/python/testapi/testworkflow.py b/test/python/testapi/testworkflow.pyindex 3cef7a44..b2dfdf8d 100644--- a/test/python/testapi/testworkflow.py+++ b/test/python/testapi/testworkflow.py@@ -37,7 +37,6 @@ workflow:labels:tasks:- action: labels- initialize: testnotfoundargs: [[positive, negative]]multiaction:tasks:diff --git a/test/python/testworkflow.py b/test/python/testworkflow.pyindex 661c80af..5fa1eaa9 100644--- a/test/python/testworkflow.py+++ b/test/python/testworkflow.py@@ -297,8 +297,8 @@ class TestWorkflow(unittest.TestCase):config = """# Embeddings indexwritable: true- scoring: bm25embeddings:+ scoring: bm25path: google/bert_uncased_L-2_H-128_A-2# Text segmentation@@ -336,3 +336,20 @@ class TestWorkflow(unittest.TestCase):list(app.workflow("segment", ["This is a test sentence. And another sentence to split."])),["This is a test sentence.", "And another sentence to split."],)++ def testYamlError(self):+ """+ Tests reading a YAML workflow with errors.+ """++ # Read from string+ config = """+ # Workflow definitions+ workflow:+ error:+ tasks:+ - action: error+ """++ with self.assertRaises(KeyError):+ API(config)