Skip to content

Conversation

@logan-markewich
Copy link
Contributor

@logan-markewich logan-markewich commented Mar 18, 2025

Add a new method and result object

Example Usage:

parser = LlamaParse(
    take_screenshot=True,
    auto_mode=True,
    fast_mode=False,
)
result = await parser.aparse(file_path)

assert isinstance(result, JobResult)
assert result.job_id is not None
assert result.file_name == file_path
assert len(result.pages) > 0

assert result.pages[0].text is not None
assert len(result.pages[0].text) > 0

assert result.pages[0].md is not None
assert len(result.pages[0].md) > 0

assert result.pages[0].md != result.pages[0].text

assert len(result.pages[0].images) > 0
assert result.pages[0].images[0].name is not None

with tempfile.TemporaryDirectory() as temp_dir:
    file_names = await result.asave_all_images(temp_dir)
    assert len(file_names) > 0
    for file_name in file_names:
        assert os.path.exists(file_name)
        assert os.path.getsize(file_name) > 0

assert result.job_metadata is not None

text_documents = result.get_text_documents(
    split_by_page=True,
)
assert len(text_documents) > 0
assert text_documents[0].text is not None
assert len(text_documents[0].text) > 0

markdown_documents = result.get_markdown_documents(
    split_by_page=True,
)
assert len(markdown_documents) > 0
assert markdown_documents[0].text is not None
assert len(markdown_documents[0].text) > 0

image_documents = result.get_image_documents()
assert len(image_documents) > 0
assert image_documents[0].image_url is not None
assert len(image_documents[0].resolve_image().getvalue()) > 0

TODO

  • Update (some) examples to use this syntax
  • Add this syntax to the readme

@logan-markewich logan-markewich marked this pull request as draft March 18, 2025 00:20
@logan-markewich logan-markewich changed the title [wip] new result object new result object Apr 9, 2025
@logan-markewich logan-markewich marked this pull request as ready for review April 9, 2025 17:48
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@logan-markewich logan-markewich merged commit fa73e73 into main Apr 11, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants