Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Replace leading file:// urls in FileTask

davidmezzetti82fd7991395f
diff --git a/src/python/txtai/workflow/task/file.py b/src/python/txtai/workflow/task/file.py
index cdd56cde..66d34249 100644
--- a/src/python/txtai/workflow/task/file.py
+++ b/src/python/txtai/workflow/task/file.py
@@ -3,6 +3,7 @@ FileTask module
"""
import os
+import re
from .base import Task
@@ -12,6 +13,16 @@ class FileTask(Task):
Task that processes file paths
"""
+ # File prefix
+ FILE = r"file:\/\/"
+
def accept(self, element):
+ # Replace file prefixes
+ element = re.sub(FileTask.FILE, "", element)
+
# Only accept file paths that exist
return super().accept(element) and isinstance(element, str) and os.path.exists(element)
+
+ def prepare(self, element):
+ # Replace file prefixes
+ return re.sub(FileTask.FILE, "", element)