pymupdf / RAG

RAG (Retrieval-Augmented Generation) Chatbot Examples Using PyMuPDF
https://pymupdf.readthedocs.io/en/latest/pymupdf4llm
GNU Affero General Public License v3.0
539 stars 82 forks source link

Accept Path object in to_markdown function #45

Closed dantetemplar closed 4 months ago

JorjMcKie commented 5 months ago

Thank you for the contribution - much appreciated! Actually, this is already supported implicitly: I just have to change the check of the parameter type. The parameter is converted to a pymupdf.Document if not already one. And Document creation supports all imaginable alternatives - including pathlib Paths. So all I need to do is something like this:

if not isinstance(arg0, pymupdf.Document):
    doc=pymupdf.open(arg0)`
else:
    doc = arg0
dantetemplar commented 5 months ago

It seems to me that this approach will spoil the types a little. I think it's better to list all the suitable alternatives in the argument annotation. But in runtime itself, the if-else that you suggested fits well.

dantetemplar commented 5 months ago

In that case, should I implement it myself?

JorjMcKie commented 5 months ago

You can of course make that change immediately in you installation files.

dantetemplar commented 5 months ago

You can of course make that change immediately in you installation files.

I mean, I've added new commit with use of pymupdf.Document

JorjMcKie commented 5 months ago

As per the type checking mannerisms of these days: I think we will reduce that a little, because the repo is still in its early development stages. So that parameter and similar one will just be typing.Any things for the time being.

dantetemplar commented 5 months ago

As per the type checking mannerisms of these days: I think we will reduce that a little, because the repo is still in its early development stages. So that parameter and similar one will just be typing.Any things for the time being.

I understand you, but the pull request can still be accepted 🤗

JorjMcKie commented 5 months ago

Ok no problem actually - except, that we need your explicit agreement to our Contributor License Agreement. We are making sure that all user contributions are backed by a well-defined legal foundation. So please add a comment somewhere here with the wording like "I have read and herewith accept the Artifex Contributor License Agreement." That agreement can be downloaded / read from this site: https://artifex.com/contributor/

dantetemplar commented 5 months ago

Ok no problem actually - except, that we need your explicit agreement to our Contributor License Agreement. We are making sure that all user contributions are backed by a well-defined legal foundation. So please add a comment somewhere here with the wording like "I have read and herewith accept the Artifex Contributor License Agreement." That agreement can be downloaded / read from this site: https://artifex.com/contributor/

I hereby declare that I have read, understood, and accept the terms and conditions of the Artifex Contributor License Agreement.

JorjMcKie commented 5 months ago

Thank you - Done!