chatterer 0.1.24__py3-none-any.whl → 0.1.26__py3-none-any.whl
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.
- chatterer/__init__.py +87 -93
- chatterer/common_types/__init__.py +21 -21
- chatterer/common_types/io.py +19 -19
- chatterer/examples/__main__.py +75 -75
- chatterer/examples/any2md.py +85 -85
- chatterer/examples/pdf2md.py +338 -338
- chatterer/examples/pdf2txt.py +54 -54
- chatterer/examples/ppt.py +486 -486
- chatterer/examples/pw.py +143 -137
- chatterer/examples/snippet.py +56 -55
- chatterer/examples/transcribe.py +192 -112
- chatterer/examples/upstage.py +89 -89
- chatterer/examples/web2md.py +80 -66
- chatterer/interactive.py +354 -354
- chatterer/language_model.py +536 -536
- chatterer/messages.py +21 -21
- chatterer/tools/__init__.py +46 -46
- chatterer/tools/caption_markdown_images.py +384 -384
- chatterer/tools/citation_chunking/__init__.py +3 -3
- chatterer/tools/citation_chunking/chunks.py +53 -53
- chatterer/tools/citation_chunking/citation_chunker.py +118 -118
- chatterer/tools/citation_chunking/citations.py +285 -285
- chatterer/tools/citation_chunking/prompt.py +157 -157
- chatterer/tools/citation_chunking/reference.py +26 -26
- chatterer/tools/citation_chunking/utils.py +138 -138
- chatterer/tools/convert_pdf_to_markdown.py +645 -625
- chatterer/tools/convert_to_text.py +446 -446
- chatterer/tools/upstage_document_parser.py +705 -705
- chatterer/tools/webpage_to_markdown.py +739 -739
- chatterer/tools/youtube.py +146 -146
- chatterer/utils/__init__.py +15 -15
- chatterer/utils/base64_image.py +350 -285
- chatterer/utils/bytesio.py +59 -59
- chatterer/utils/code_agent.py +237 -237
- chatterer/utils/imghdr.py +145 -148
- {chatterer-0.1.24.dist-info → chatterer-0.1.26.dist-info}/METADATA +390 -389
- chatterer-0.1.26.dist-info/RECORD +42 -0
- chatterer/strategies/__init__.py +0 -13
- chatterer/strategies/atom_of_thoughts.py +0 -975
- chatterer/strategies/base.py +0 -14
- chatterer-0.1.24.dist-info/RECORD +0 -45
- {chatterer-0.1.24.dist-info → chatterer-0.1.26.dist-info}/WHEEL +0 -0
- {chatterer-0.1.24.dist-info → chatterer-0.1.26.dist-info}/entry_points.txt +0 -0
- {chatterer-0.1.24.dist-info → chatterer-0.1.26.dist-info}/top_level.txt +0 -0
chatterer/examples/pdf2txt.py
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
import logging
|
2
|
-
import sys
|
3
|
-
from pathlib import Path
|
4
|
-
from typing import Optional
|
5
|
-
|
6
|
-
from spargear import RunnableArguments
|
7
|
-
|
8
|
-
from chatterer.tools.convert_to_text import pdf_to_text
|
9
|
-
|
10
|
-
logger = logging.getLogger(__name__)
|
11
|
-
|
12
|
-
|
13
|
-
class Arguments(RunnableArguments[None]):
|
14
|
-
PDF_PATH: Path
|
15
|
-
"""Path to the PDF file to convert to text."""
|
16
|
-
output: Optional[Path]
|
17
|
-
"""Path to the output text file. If not provided, defaults to the input file with a .txt suffix."""
|
18
|
-
page: Optional[str] = None
|
19
|
-
"""Comma-separated list of zero-based page indices to extract from the PDF. Supports ranges, e.g., '0,2,4-8'."""
|
20
|
-
|
21
|
-
def run(self) -> None:
|
22
|
-
input = self.PDF_PATH.resolve()
|
23
|
-
out = self.output or input.with_suffix(".txt")
|
24
|
-
if not input.is_file():
|
25
|
-
sys.exit(1)
|
26
|
-
out.write_text(
|
27
|
-
pdf_to_text(path_or_file=input, page_indices=self.page),
|
28
|
-
encoding="utf-8",
|
29
|
-
)
|
30
|
-
logger.info(f"Extracted text from `{input}` to `{out}`")
|
31
|
-
|
32
|
-
|
33
|
-
def parse_page_indices(pages_str: str) -> list[int]:
|
34
|
-
indices: set[int] = set()
|
35
|
-
for part in pages_str.split(","):
|
36
|
-
part = part.strip()
|
37
|
-
if "-" in part:
|
38
|
-
start_str, end_str = part.split("-", 1)
|
39
|
-
start = int(start_str)
|
40
|
-
end = int(end_str)
|
41
|
-
if start > end:
|
42
|
-
raise ValueError
|
43
|
-
indices.update(range(start, end + 1))
|
44
|
-
else:
|
45
|
-
indices.add(int(part))
|
46
|
-
return sorted(indices)
|
47
|
-
|
48
|
-
|
49
|
-
def main() -> None:
|
50
|
-
Arguments().run()
|
51
|
-
|
52
|
-
|
53
|
-
if __name__ == "__main__":
|
54
|
-
main()
|
1
|
+
import logging
|
2
|
+
import sys
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import Optional
|
5
|
+
|
6
|
+
from spargear import RunnableArguments
|
7
|
+
|
8
|
+
from chatterer.tools.convert_to_text import pdf_to_text
|
9
|
+
|
10
|
+
logger = logging.getLogger(__name__)
|
11
|
+
|
12
|
+
|
13
|
+
class Arguments(RunnableArguments[None]):
|
14
|
+
PDF_PATH: Path
|
15
|
+
"""Path to the PDF file to convert to text."""
|
16
|
+
output: Optional[Path]
|
17
|
+
"""Path to the output text file. If not provided, defaults to the input file with a .txt suffix."""
|
18
|
+
page: Optional[str] = None
|
19
|
+
"""Comma-separated list of zero-based page indices to extract from the PDF. Supports ranges, e.g., '0,2,4-8'."""
|
20
|
+
|
21
|
+
def run(self) -> None:
|
22
|
+
input = self.PDF_PATH.resolve()
|
23
|
+
out = self.output or input.with_suffix(".txt")
|
24
|
+
if not input.is_file():
|
25
|
+
sys.exit(1)
|
26
|
+
out.write_text(
|
27
|
+
pdf_to_text(path_or_file=input, page_indices=self.page),
|
28
|
+
encoding="utf-8",
|
29
|
+
)
|
30
|
+
logger.info(f"Extracted text from `{input}` to `{out}`")
|
31
|
+
|
32
|
+
|
33
|
+
def parse_page_indices(pages_str: str) -> list[int]:
|
34
|
+
indices: set[int] = set()
|
35
|
+
for part in pages_str.split(","):
|
36
|
+
part = part.strip()
|
37
|
+
if "-" in part:
|
38
|
+
start_str, end_str = part.split("-", 1)
|
39
|
+
start = int(start_str)
|
40
|
+
end = int(end_str)
|
41
|
+
if start > end:
|
42
|
+
raise ValueError
|
43
|
+
indices.update(range(start, end + 1))
|
44
|
+
else:
|
45
|
+
indices.add(int(part))
|
46
|
+
return sorted(indices)
|
47
|
+
|
48
|
+
|
49
|
+
def main() -> None:
|
50
|
+
Arguments().run()
|
51
|
+
|
52
|
+
|
53
|
+
if __name__ == "__main__":
|
54
|
+
main()
|