💡 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
Code cleanup
davidmezzettiac2dc6a30ba6
diff --git a/test/python/testworkflow.py b/test/python/testworkflow.pyindex 7ff183d6..b84a4c76 100644--- a/test/python/testworkflow.py+++ b/test/python/testworkflow.py@@ -27,7 +27,6 @@ from txtai.workflow import (RetrieveTask,StorageTask,TemplateTask,- UrlTask,WorkflowTask,)@@ -215,37 +214,29 @@ class TestWorkflow(unittest.TestCase):results = list(workflow([1]))self.assertEqual(results[0], 1)- def testImageWorkflow(self):+ def testFileWorkflow(self):"""- Test an image task+ Test a file task"""- workflow = Workflow([ImageTask()])-- results = list(workflow([Utils.PATH + "/books.jpg"]))+ with tempfile.NamedTemporaryFile() as temp:+ # String and non-string elements+ inputs = [temp.name, "http://example.com", 5, None, "no match here"]- self.assertEqual(results[0].size, (1024, 682))+ workflow = Workflow([FileTask()])+ results = list(workflow(inputs))+ self.assertEqual(results, inputs)- def testFileUrlTaskNonStringElements(self):+ def testImageWorkflow(self):"""- Test that FileTask/UrlTask/ImageTask pass through non-string and non-matching- elements instead of crashing, matching the base Task.accept contract for- heterogeneous batches.+ Test an image task"""- with tempfile.NamedTemporaryFile() as temp:- # Elements: a real file path (matches FileTask), a url (matches UrlTask),- # a non-string, None and a non-matching string - none of these should crash.- data = [temp.name, "http://example.com", 5, None, "no match here"]-- urls = list(Workflow([UrlTask(lambda x: [y.upper() for y in x])])(list(data)))- self.assertEqual(urls, [temp.name, "HTTP://EXAMPLE.COM", 5, None, "no match here"])+ workflow = Workflow([ImageTask()])- files = list(Workflow([FileTask(lambda x: [f.upper() for f in x])])(list(data)))- self.assertEqual(files, [temp.name.upper(), "http://example.com", 5, None, "no match here"])+ results = list(workflow([Utils.PATH + "/books.jpg"]))- images = list(Workflow([ImageTask()])(list(data)))- self.assertEqual(images, [temp.name, "http://example.com", 5, None, "no match here"])+ self.assertEqual(results[0].size, (1024, 682))def testInvalidWorkflow(self):"""