💡 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
Handle file urls more consistently, closes #151
davidmezzetti59f6abe492bb
diff --git a/src/python/txtai/pipeline/segment/textractor.py b/src/python/txtai/pipeline/segment/textractor.pyindex 8af4a0f2..c666cb06 100644--- a/src/python/txtai/pipeline/segment/textractor.py+++ b/src/python/txtai/pipeline/segment/textractor.py@@ -38,6 +38,9 @@ class Textractor(Segmentation):def text(self, text):# Use Tika if availableif self.tika:+ # Format file urls as local file paths+ text = text.replace("file://", "")+# text is a path to a fileparsed = parser.from_file(text)return parsed["content"]diff --git a/src/python/txtai/workflow/task/file.py b/src/python/txtai/workflow/task/file.pyindex 895b064e..cdd56cde 100644--- a/src/python/txtai/workflow/task/file.py+++ b/src/python/txtai/workflow/task/file.py@@ -2,16 +2,16 @@FileTask module"""-import re+import os-from .url import UrlTask+from .base import Task-class FileTask(UrlTask):+class FileTask(Task):"""- Task that processes file urls+ Task that processes file paths"""def accept(self, element):- # Only accept file URLs- return super().accept(element) and re.match(UrlTask.FILE, element.lower())+ # Only accept file paths that exist+ return super().accept(element) and isinstance(element, str) and os.path.exists(element)diff --git a/src/python/txtai/workflow/task/url.py b/src/python/txtai/workflow/task/url.pyindex 9eba7fab..355e06b7 100644--- a/src/python/txtai/workflow/task/url.py+++ b/src/python/txtai/workflow/task/url.py@@ -15,12 +15,6 @@ class UrlTask(Task):# URL prefixPREFIX = r"\w+:\/\/"- # File prefix- FILE = r"file:\/\/"-def accept(self, element):# Only accept file URLsreturn super().accept(element) and re.match(UrlTask.PREFIX, element.lower())-- def prepare(self, element):- return re.sub(UrlTask.FILE, "", element)