Skip to content

Commit 16b4630

Browse files
committed
remove nested containers
1 parent cbe00e7 commit 16b4630

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/axiomatic/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Dict
55

66
from .base_client import BaseClient, AsyncBaseClient
7-
from . import MdResponse
7+
from . import ParseResponse
88

99

1010
class Axiomatic(BaseClient):
@@ -24,18 +24,18 @@ class DocumentHelper:
2424
def __init__(self, ax_client: Axiomatic):
2525
self._ax_client = ax_client
2626

27-
def pdf_from_url(self, url: str) -> MdResponse:
27+
def pdf_from_url(self, url: str) -> ParseResponse:
2828
"""Download a PDF document from a URL and parse it into a Markdown response."""
2929
file = requests.get(url)
3030
response = self._ax_client.document.parse(file=file.content)
31-
return response.content
31+
return response
3232

33-
def pdf_from_file(self, path: str) -> MdResponse:
33+
def pdf_from_file(self, path: str) -> ParseResponse:
3434
"""Open a PDF document from a file path and parse it into a Markdown response."""
3535
with open(path, "rb") as f:
3636
file = f.read()
3737
response = self._ax_client.document.parse(file=file)
38-
return response.content
38+
return response
3939

4040
def plot_b64_images(self, images: Dict[str, str]):
4141
"""Plot a dictionary of base64 images."""
@@ -65,7 +65,7 @@ def navigate_image(change):
6565
display(layout)
6666
display_base64_image(current_index[0])
6767

68-
def save_parsed_pdf(self, response: MdResponse, path: str):
68+
def save_parsed_pdf(self, response: ParseResponse, path: str):
6969
"""Save a parsed PDF response to a file."""
7070
os.makedirs(path, exist_ok=True)
7171
for img_name, img in response.images.items():
@@ -75,7 +75,7 @@ def save_parsed_pdf(self, response: MdResponse, path: str):
7575
with open(os.path.join(path, "text.md"), "w") as f:
7676
f.write(response.markdown)
7777

78-
def load_parsed_pdf(self, path: str) -> MdResponse:
78+
def load_parsed_pdf(self, path: str) -> ParseResponse:
7979
"""Load a parsed PDF response from a file."""
8080
with open(os.path.join(path, "text.md"), "r") as f:
8181
markdown = f.read()
@@ -86,7 +86,7 @@ def load_parsed_pdf(self, path: str) -> MdResponse:
8686
with open(os.path.join(path, img_name), "rb") as img_file:
8787
images[img_name] = base64.b64encode(img_file.read()).decode("utf-8")
8888

89-
return MdResponse(markdown=markdown, images=images)
89+
return ParseResponse(markdown=markdown, images=images)
9090

9191

9292
class AsyncAxiomatic(AsyncBaseClient): ...

0 commit comments

Comments
 (0)