Skip to content

armgit / txtai

Public Imported from GitHub
0

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

Code cleanup

davidmezzettia6a61bd4a82c
diff --git a/src/python/txtai/models/models.py b/src/python/txtai/models/models.py
index 2d1e6f6b..c64dc2d2 100644
--- a/src/python/txtai/models/models.py
+++ b/src/python/txtai/models/models.py
@@ -32,7 +32,7 @@ class Models:
if hasattr(config, "config"):
config = config.config
- if hasattr(config, "max_position_embeddings") and tokenizer.model_max_length == int(1e30):
+ if hasattr(config, "max_position_embeddings") and tokenizer and tokenizer.model_max_length == int(1e30):
tokenizer.model_max_length = config.max_position_embeddings
@staticmethod
diff --git a/src/python/txtai/workflow/task/image.py b/src/python/txtai/workflow/task/image.py
index 68c7a732..8c44444d 100644
--- a/src/python/txtai/workflow/task/image.py
+++ b/src/python/txtai/workflow/task/image.py
@@ -27,7 +27,7 @@ class ImageTask(FileTask):
super().__init__(action, select, unpack)
def accept(self, element):
- # Only accept file URLs
+ # Only accept image files
return super().accept(element) and re.search(r"\.(gif|bmp|jpg|jpeg|png|webp)$", element.lower())
def prepare(self, element):
diff --git a/test/python/testtextractor.py b/test/python/testtextractor.py
index 4420a6c9..f283ee9a 100644
--- a/test/python/testtextractor.py
+++ b/test/python/testtextractor.py
@@ -32,6 +32,19 @@ class TestTextractor(unittest.TestCase):
textractor = Textractor()
self.assertFalse(textractor.checkjava("1112444abc"))
+ def testLines(self):
+ """
+ Tests extraction to lines
+ """
+
+ textractor = Textractor(lines=True)
+
+ # Extract text as lines
+ lines = textractor(Utils.PATH + "/article.pdf")
+
+ # Check number of lines is as expected
+ self.assertEqual(len(lines), 35)
+
def testParagraphs(self):
"""
Tests extraction to paragraphs