💡 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
Update commonprefix to commonpath, closes #1120
davidmezzetti13b1a0f986e4
diff --git a/src/python/txtai/archive/compress.py b/src/python/txtai/archive/compress.pyindex 739b201b..2411ba70 100644--- a/src/python/txtai/archive/compress.py+++ b/src/python/txtai/archive/compress.py@@ -46,6 +46,6 @@ class Compress:directory = os.path.abspath(directory)path = os.path.abspath(path)- prefix = os.path.commonprefix([directory, path])+ prefix = os.path.commonpath([directory, path])return prefix == directorydiff --git a/src/python/txtai/pipeline/data/textractor.py b/src/python/txtai/pipeline/data/textractor.pyindex ed802ac1..e4ee99ad 100644--- a/src/python/txtai/pipeline/data/textractor.py+++ b/src/python/txtai/pipeline/data/textractor.py@@ -167,7 +167,7 @@ class Textractor(Segmentation):if os.path.exists(url):# Validate local file is in safe pathpath = os.path.realpath(url)- prefix = os.path.commonprefix([self.safeopen, path])+ prefix = os.path.commonpath([self.safeopen, path])valid = prefix == self.safeopenelse:# URL validationdiff --git a/test/python/testapi/testapipipeline.py b/test/python/testapi/testapipipeline.pyindex e68fe09f..8bf3fb24 100644--- a/test/python/testapi/testapipipeline.py+++ b/test/python/testapi/testapipipeline.py@@ -125,6 +125,12 @@ class TestPipeline(unittest.TestCase):"that enables Natural Language Understanding (NLU) based search in any application.")+ # Create invalid test file+ directory = os.path.join(tempfile.gettempdir(), "txtai-1")+ os.makedirs(directory, exist_ok=True)+ with open(os.path.join(directory, "test"), "w", encoding="utf-8") as output:+ output.write("123")+def testCaption(self):"""Test caption via API@@ -314,7 +320,7 @@ class TestPipeline(unittest.TestCase):self.assertEqual(len(text), 2471)# Check invalid URLs- for url in ["http://192.168.1.1/path", "http://127.0.0.1/path", "http://invalid", "/etc/config"]:+ for url in ["http://192.168.1.1/path", "http://127.0.0.1/path", "http://invalid", "/etc/config", "/tmp/txtai-1/test"]:with self.assertRaises(IOError):self.client.get(f"textract?file={url}").json()