HowdenParser 6.0.0__tar.gz → 6.0.1__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-6.0.0 → howdenparser-6.0.1}/HowdenParser/parsers/llama_parser.py +22 -10
- {howdenparser-6.0.0 → howdenparser-6.0.1}/PKG-INFO +1 -1
- {howdenparser-6.0.0 → howdenparser-6.0.1}/pyproject.toml +44 -44
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/__init__.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/parameter/__init__.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/parameter/llamaparser.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/parameter/mistralocr.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/parser.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/parsers/__init__.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/parsers/langchain_parser.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/HowdenParser/parsers/mistral_parser.py +0 -0
- {howdenparser-6.0.0 → howdenparser-6.0.1}/README.md +0 -0
|
@@ -4,11 +4,12 @@ from pathlib import Path
|
|
|
4
4
|
from ..parser import BaseParser
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
class LlamaParser(BaseParser, name="llamaparser"):
|
|
8
9
|
def __init__(self,
|
|
9
10
|
result_type: str,
|
|
10
|
-
tier: str,
|
|
11
|
-
version: str,
|
|
11
|
+
tier: str, # One of: ["fast", "cost_effective", "agentic", "agentic_plus"]
|
|
12
|
+
version: str, # one of: ["latest","2026-03-12","2026-03-11"...] (many not listed)
|
|
12
13
|
provider_and_model: str,
|
|
13
14
|
merge_continued_tables: bool,
|
|
14
15
|
preserve_layout_alignment_across_pages: bool,
|
|
@@ -48,10 +49,13 @@ class LlamaParser(BaseParser, name="llamaparser"):
|
|
|
48
49
|
if not api_key:
|
|
49
50
|
raise EnvironmentError("Missing LLAMA-PARSER-API-TOKEN in .env file.")
|
|
50
51
|
|
|
51
|
-
rt_lower = str(
|
|
52
|
-
|
|
52
|
+
rt_lower = str(
|
|
53
|
+
self.result_type).lower() # Possible values for LlamaCloud expand: ["markdown", "markdown_full", "text", "metadata", "items"]
|
|
54
|
+
if rt_lower in ("md", "markdown"):
|
|
53
55
|
self.rt = 'markdown'
|
|
54
|
-
elif rt_lower in ("
|
|
56
|
+
elif rt_lower in ("md_full", "markdown_full"):
|
|
57
|
+
self.rt = 'markdown_full'
|
|
58
|
+
elif rt_lower in ("txt", "text"):
|
|
55
59
|
self.rt = 'text'
|
|
56
60
|
elif rt_lower in ("json"):
|
|
57
61
|
self.rt = 'items'
|
|
@@ -65,6 +69,7 @@ class LlamaParser(BaseParser, name="llamaparser"):
|
|
|
65
69
|
def parse(self, file_path: Path, include_pagenumbers: bool = False) -> Any:
|
|
66
70
|
# Ensure parser is created inside the thread event loop
|
|
67
71
|
self._lazy_init()
|
|
72
|
+
|
|
68
73
|
def page_break(text: str, idx: int) -> str:
|
|
69
74
|
return f"<PAGE_NUMBER {idx}>{text}</PAGE_NUMBER {idx}>"
|
|
70
75
|
|
|
@@ -87,11 +92,18 @@ class LlamaParser(BaseParser, name="llamaparser"):
|
|
|
87
92
|
)
|
|
88
93
|
|
|
89
94
|
if self.rt == 'markdown':
|
|
90
|
-
if include_pagenumbers:
|
|
91
|
-
|
|
95
|
+
if include_pagenumbers:
|
|
96
|
+
return "\n".join(
|
|
97
|
+
page_break(page.markdown, idx) for idx, page in enumerate(documents.markdown.pages, start=1))
|
|
98
|
+
else:
|
|
99
|
+
return "\n".join(page.markdown for page in documents.markdown.pages)
|
|
100
|
+
elif self.rt == 'markdown_full':
|
|
101
|
+
return documents.markdown_full
|
|
92
102
|
elif self.rt == 'text':
|
|
93
|
-
if include_pagenumbers:
|
|
94
|
-
|
|
103
|
+
if include_pagenumbers:
|
|
104
|
+
return "\n".join(page_break(page.text, idx) for idx, page in enumerate(documents.text.pages, start=1))
|
|
105
|
+
else:
|
|
106
|
+
return "\n".join(page.text for page in documents.text.pages)
|
|
95
107
|
elif self.rt == 'items':
|
|
96
108
|
return documents.model_dump()
|
|
97
109
|
else:
|
|
@@ -101,4 +113,4 @@ class LlamaParser(BaseParser, name="llamaparser"):
|
|
|
101
113
|
return self.parse(file_path)
|
|
102
114
|
|
|
103
115
|
def write_json_hyperparameter(self, folder_file_path: Path) -> None:
|
|
104
|
-
self.write_parameters(self._input_params, folder_file_path)
|
|
116
|
+
self.write_parameters(self._input_params, folder_file_path)
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
[project]
|
|
2
|
-
name = "HowdenParser"
|
|
3
|
-
version = "6.0.
|
|
4
|
-
description = "A simple configuration manager with Pydantic and JSON export."
|
|
5
|
-
readme = "README.md"
|
|
6
|
-
requires-python = ">=3.12,<3.14"
|
|
7
|
-
authors = [
|
|
8
|
-
{ name = "JesperThoftIllemannJ", email = "jesper.jaeger@howdendanmark.dk" },
|
|
9
|
-
]
|
|
10
|
-
keywords = [
|
|
11
|
-
"config",
|
|
12
|
-
"configuration",
|
|
13
|
-
"pydantic",
|
|
14
|
-
"json",
|
|
15
|
-
]
|
|
16
|
-
homepage = "https://github.com/yourusername/config"
|
|
17
|
-
repository = "https://github.com/yourusername/config"
|
|
18
|
-
documentation = "https://github.com/yourusername/config"
|
|
19
|
-
dependencies = [
|
|
20
|
-
"mistralai (>=1.9.3,<2.0.0)",
|
|
21
|
-
"llama-cloud (>=1.0)",
|
|
22
|
-
"pypdf2 (>=3.0.1,<4.0.0)",
|
|
23
|
-
"pdf2image (>=1.17.0,<2.0.0)",
|
|
24
|
-
"langchain (>=1.1.3,<2.0.0)",
|
|
25
|
-
"pytest (>=9.0.2,<10.0.0)",
|
|
26
|
-
"tomli-w (>=1.2.0,<2.0.0)",
|
|
27
|
-
"dotenv (>=0.9.9,<0.10.0)",
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
[project.license]
|
|
31
|
-
text = "MIT"
|
|
32
|
-
|
|
33
|
-
[build-system]
|
|
34
|
-
requires = [
|
|
35
|
-
"poetry-core>=2.0.0,<3.0.0",
|
|
36
|
-
]
|
|
37
|
-
build-backend = "poetry.core.masonry.api"
|
|
38
|
-
|
|
39
|
-
[dependency-groups]
|
|
40
|
-
dev = [
|
|
41
|
-
"toml (>=0.10.2,<0.11.0)",
|
|
42
|
-
"tomli-w (>=1.2.0,<2.0.0)",
|
|
43
|
-
"howdenconfig (>=1.0.6,<2.0.0)",
|
|
44
|
-
]
|
|
1
|
+
[project]
|
|
2
|
+
name = "HowdenParser"
|
|
3
|
+
version = "6.0.1"
|
|
4
|
+
description = "A simple configuration manager with Pydantic and JSON export."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12,<3.14"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "JesperThoftIllemannJ", email = "jesper.jaeger@howdendanmark.dk" },
|
|
9
|
+
]
|
|
10
|
+
keywords = [
|
|
11
|
+
"config",
|
|
12
|
+
"configuration",
|
|
13
|
+
"pydantic",
|
|
14
|
+
"json",
|
|
15
|
+
]
|
|
16
|
+
homepage = "https://github.com/yourusername/config"
|
|
17
|
+
repository = "https://github.com/yourusername/config"
|
|
18
|
+
documentation = "https://github.com/yourusername/config"
|
|
19
|
+
dependencies = [
|
|
20
|
+
"mistralai (>=1.9.3,<2.0.0)",
|
|
21
|
+
"llama-cloud (>=1.0)",
|
|
22
|
+
"pypdf2 (>=3.0.1,<4.0.0)",
|
|
23
|
+
"pdf2image (>=1.17.0,<2.0.0)",
|
|
24
|
+
"langchain (>=1.1.3,<2.0.0)",
|
|
25
|
+
"pytest (>=9.0.2,<10.0.0)",
|
|
26
|
+
"tomli-w (>=1.2.0,<2.0.0)",
|
|
27
|
+
"dotenv (>=0.9.9,<0.10.0)",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.license]
|
|
31
|
+
text = "MIT"
|
|
32
|
+
|
|
33
|
+
[build-system]
|
|
34
|
+
requires = [
|
|
35
|
+
"poetry-core>=2.0.0,<3.0.0",
|
|
36
|
+
]
|
|
37
|
+
build-backend = "poetry.core.masonry.api"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"toml (>=0.10.2,<0.11.0)",
|
|
42
|
+
"tomli-w (>=1.2.0,<2.0.0)",
|
|
43
|
+
"howdenconfig (>=1.0.6,<2.0.0)",
|
|
44
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|