HowdenParser 5.2.5__tar.gz → 6.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parser.py +3 -5
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parsers/llama_parser.py +43 -34
- {howdenparser-5.2.5 → howdenparser-6.0.0}/PKG-INFO +3 -2
- {howdenparser-5.2.5 → howdenparser-6.0.0}/pyproject.toml +3 -2
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/__init__.py +0 -0
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parameter/__init__.py +0 -0
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parameter/llamaparser.py +0 -0
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parameter/mistralocr.py +0 -0
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parsers/__init__.py +0 -0
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parsers/langchain_parser.py +0 -0
- {howdenparser-5.2.5 → howdenparser-6.0.0}/HowdenParser/parsers/mistral_parser.py +0 -0
- {howdenparser-5.2.5 → howdenparser-6.0.0}/README.md +0 -0
|
@@ -96,13 +96,11 @@ class Parser(BaseParser):
|
|
|
96
96
|
cls,
|
|
97
97
|
*,
|
|
98
98
|
provider_and_model: Literal["llamaparser:"],
|
|
99
|
+
tier: str,
|
|
100
|
+
version: str,
|
|
99
101
|
result_type: str,
|
|
100
|
-
model: str,
|
|
101
|
-
parse_mode: str,
|
|
102
102
|
preserve_layout_alignment_across_pages: bool,
|
|
103
|
-
|
|
104
|
-
hide_footers: bool,
|
|
105
|
-
hide_headers: bool,
|
|
103
|
+
merge_continued_tables: bool,
|
|
106
104
|
) -> "LlamaParser": ...
|
|
107
105
|
|
|
108
106
|
@overload
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import json
|
|
3
2
|
import logging
|
|
4
3
|
from pathlib import Path
|
|
5
4
|
from ..parser import BaseParser
|
|
6
5
|
from typing import Any
|
|
7
|
-
from llama_parse import ResultType
|
|
8
6
|
|
|
9
7
|
class LlamaParser(BaseParser, name="llamaparser"):
|
|
10
|
-
def __init__(self,
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
def __init__(self,
|
|
9
|
+
result_type: str,
|
|
10
|
+
tier: str, # One of: ["fast", "cost_effective", "agentic", "agentic_plus"]
|
|
11
|
+
version: str, # one of: ["latest","2026-03-12","2026-03-11"...] (many not listed)
|
|
12
|
+
provider_and_model: str,
|
|
13
|
+
merge_continued_tables: bool,
|
|
14
|
+
preserve_layout_alignment_across_pages: bool,
|
|
15
|
+
) -> None:
|
|
13
16
|
|
|
14
17
|
super().__init__()
|
|
15
18
|
# Capture only input parameters
|
|
@@ -23,50 +26,39 @@ class LlamaParser(BaseParser, name="llamaparser"):
|
|
|
23
26
|
|
|
24
27
|
# Store configuration only
|
|
25
28
|
self.result_type = result_type
|
|
26
|
-
self.
|
|
27
|
-
self.
|
|
29
|
+
self.tier = tier
|
|
30
|
+
self.version = version
|
|
28
31
|
self.provider_and_model = provider_and_model
|
|
29
|
-
self.
|
|
32
|
+
self.merge_continued_tables = merge_continued_tables
|
|
30
33
|
self.preserve_layout_alignment_across_pages = preserve_layout_alignment_across_pages
|
|
31
|
-
self.hide_footers = hide_footers
|
|
32
|
-
self.hide_headers = hide_headers
|
|
33
34
|
self.hashed = self.compute_hash(self._input_params)
|
|
34
35
|
# DO NOT CREATE LlamaParse HERE
|
|
35
36
|
# It creates asyncio objects bound to the wrong loop
|
|
36
37
|
self._parser = None
|
|
38
|
+
self.rt = None
|
|
37
39
|
|
|
38
40
|
def _lazy_init(self):
|
|
39
41
|
"""Initialize LlamaParse inside the worker thread event loop."""
|
|
40
42
|
if self._parser is not None:
|
|
41
43
|
return
|
|
42
44
|
|
|
43
|
-
from
|
|
45
|
+
from llama_cloud import LlamaCloud
|
|
44
46
|
|
|
45
47
|
api_key = os.getenv("LLAMA-PARSER-API-TOKEN")
|
|
46
48
|
if not api_key:
|
|
47
49
|
raise EnvironmentError("Missing LLAMA-PARSER-API-TOKEN in .env file.")
|
|
48
50
|
|
|
49
|
-
rt_lower = str(self.result_type).lower()
|
|
51
|
+
rt_lower = str(self.result_type).lower() # Possible values for LlamaCloud expand: ["markdown", "text", "metadata", "items"]
|
|
50
52
|
if rt_lower in ("md","markdown"):
|
|
51
|
-
rt =
|
|
53
|
+
self.rt = 'markdown'
|
|
52
54
|
elif rt_lower in ("txt","text"):
|
|
53
|
-
rt =
|
|
55
|
+
self.rt = 'text'
|
|
54
56
|
elif rt_lower in ("json"):
|
|
55
|
-
rt =
|
|
57
|
+
self.rt = 'items'
|
|
56
58
|
else:
|
|
57
59
|
raise NotImplementedError(f"Result type {self.result_type} is not supported.")
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
self._parser = LlamaParse(
|
|
61
|
-
api_key=api_key,
|
|
62
|
-
result_type=rt,
|
|
63
|
-
model=self.model,
|
|
64
|
-
parse_mode=self.parse_mode,
|
|
65
|
-
merge_tables_across_pages_in_markdown=self.merge_tables_across_pages_in_markdown,
|
|
66
|
-
preserve_layout_alignment_across_pages=self.preserve_layout_alignment_across_pages,
|
|
67
|
-
hide_footers=self.hide_footers,
|
|
68
|
-
hide_headers=self.hide_headers,
|
|
69
|
-
)
|
|
61
|
+
self._parser = LlamaCloud(api_key=os.getenv("LLAMA-PARSER-API-TOKEN"))
|
|
70
62
|
|
|
71
63
|
logging.info("LlamaParser initialized inside worker thread")
|
|
72
64
|
|
|
@@ -76,14 +68,31 @@ class LlamaParser(BaseParser, name="llamaparser"):
|
|
|
76
68
|
def page_break(text: str, idx: int) -> str:
|
|
77
69
|
return f"<PAGE_NUMBER {idx}>{text}</PAGE_NUMBER {idx}>"
|
|
78
70
|
|
|
79
|
-
documents = self._parser.parse(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
documents = self._parser.parsing.parse(
|
|
72
|
+
upload_file=file_path,
|
|
73
|
+
tier=self.tier,
|
|
74
|
+
version=self.version,
|
|
75
|
+
output_options={
|
|
76
|
+
"markdown": {
|
|
77
|
+
"tables": {
|
|
78
|
+
"output_tables_as_markdown": True,
|
|
79
|
+
"merge_continued_tables": self.merge_continued_tables,
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"spatial_text": {
|
|
83
|
+
"preserve_layout_alignment_across_pages": self.preserve_layout_alignment_across_pages,
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
expand=[self.rt],
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if self.rt == 'markdown':
|
|
90
|
+
if include_pagenumbers: return "\n".join(page_break(page.markdown, idx) for idx, page in enumerate(documents.markdown.pages, start=1))
|
|
91
|
+
else: return "\n".join(page.markdown for page in documents.markdown.pages)
|
|
92
|
+
elif self.rt == 'text':
|
|
93
|
+
if include_pagenumbers: return "\n".join(page_break(page.text, idx) for idx, page in enumerate(documents.text.pages, start=1))
|
|
94
|
+
else: return "\n".join(page.text for page in documents.text.pages)
|
|
95
|
+
elif self.rt == 'items':
|
|
87
96
|
return documents.model_dump()
|
|
88
97
|
else:
|
|
89
98
|
raise NotImplementedError(f"Result type {self.result_type} is not supported.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: HowdenParser
|
|
3
|
-
Version:
|
|
3
|
+
Version: 6.0.0
|
|
4
4
|
Summary: A simple configuration manager with Pydantic and JSON export.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: config,configuration,pydantic,json
|
|
@@ -11,8 +11,9 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Requires-Dist: dotenv (>=0.9.9,<0.10.0)
|
|
14
15
|
Requires-Dist: langchain (>=1.1.3,<2.0.0)
|
|
15
|
-
Requires-Dist: llama-
|
|
16
|
+
Requires-Dist: llama-cloud (>=1.0)
|
|
16
17
|
Requires-Dist: mistralai (>=1.9.3,<2.0.0)
|
|
17
18
|
Requires-Dist: pdf2image (>=1.17.0,<2.0.0)
|
|
18
19
|
Requires-Dist: pypdf2 (>=3.0.1,<4.0.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "HowdenParser"
|
|
3
|
-
version = "
|
|
3
|
+
version = "6.0.0"
|
|
4
4
|
description = "A simple configuration manager with Pydantic and JSON export."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12,<3.14"
|
|
@@ -18,12 +18,13 @@ repository = "https://github.com/yourusername/config"
|
|
|
18
18
|
documentation = "https://github.com/yourusername/config"
|
|
19
19
|
dependencies = [
|
|
20
20
|
"mistralai (>=1.9.3,<2.0.0)",
|
|
21
|
-
"llama-
|
|
21
|
+
"llama-cloud (>=1.0)",
|
|
22
22
|
"pypdf2 (>=3.0.1,<4.0.0)",
|
|
23
23
|
"pdf2image (>=1.17.0,<2.0.0)",
|
|
24
24
|
"langchain (>=1.1.3,<2.0.0)",
|
|
25
25
|
"pytest (>=9.0.2,<10.0.0)",
|
|
26
26
|
"tomli-w (>=1.2.0,<2.0.0)",
|
|
27
|
+
"dotenv (>=0.9.9,<0.10.0)",
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
[project.license]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|