markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

feat: Add support for custom LLM describers

Open Jhonnyr97 opened this issue 4 months ago • 2 comments

This PR addresses issue #1129 by introducing a flexible and extensible way to use any multimodal Large Language Model for image descriptions, not just OpenAI models.

Instead of hardcoding support for specific LLM providers like Gemini or Claude, this PR introduces a new llm_describber callback function. This allows users to define their own logic for generating image descriptions, making the library compatible with any LLM provider.

Key Changes:

  • The MarkItDown class now accepts an llm_describber function in its constructor.
  • The llm_describber is propagated to all converters that handle image descriptions (ImageConverter, PptxConverter).
  • The implementation is backward-compatible. If llm_describber is not provided, the library falls back to the existing llm_client/llm_model logic for OpenAI models.
  • Added a new test to ensure the llm_describber is called correctly.
  • Updated the README.md to document the new functionality.

Example Usage:

from markitdown import MarkItDown

def my_custom_describber(data_uri: str, prompt: str) -> str:
    # Add logic to call any LLM API
    return f"Custom description for prompt '{prompt}'"

md = MarkItDown(llm_describber=my_custom_describber)
result = md.convert("my_image.jpg")
print(result.markdown)

This approach provides maximum flexibility and avoids the need to add specific support for each new LLM provider in the future.

Jhonnyr97 avatar Oct 16 '25 11:10 Jhonnyr97

@microsoft-github-policy-service agree

Jhonnyr97 avatar Oct 23 '25 09:10 Jhonnyr97

@Jhonnyr97 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

Jhonnyr97 avatar Oct 31 '25 16:10 Jhonnyr97