💡 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 clear error when starting API and config file not found, closes #412
davidmezzettie2e903663956
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.pyindex 820644b1..7983a432 100644--- a/src/python/txtai/app/base.py+++ b/src/python/txtai/app/base.py@@ -38,9 +38,14 @@ class Application:with open(data, "r", encoding="utf-8") as f:# Read configurationreturn yaml.safe_load(f)- else:- # Read yaml from string- return yaml.safe_load(data)++ # Attempt to read yaml from input+ data = yaml.safe_load(data)+ if not isinstance(data, str):+ return data++ # File not found and input is not yaml, raise error+ raise FileNotFoundError(f"Unable to load file '{data}'")# Return unmodifiedreturn datadiff --git a/test/python/testapp.py b/test/python/testapp.pynew file mode 100644index 00000000..4f153dd1--- /dev/null+++ b/test/python/testapp.py@@ -0,0 +1,21 @@+"""+Application module tests+"""++import unittest++from txtai.app import Application+++class TestApp(unittest.TestCase):+ """+ Application tests.+ """++ def testConfig(self):+ """+ Tests a file not found config exception+ """++ with self.assertRaises(FileNotFoundError):+ Application.read("No file here")