Skip to content

Conversation

@Jhonnyr97
Copy link

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 and others added 3 commits October 16, 2025 13:18
This commit introduces a new `llm_describber` callback to provide a flexible and extensible way to integrate any multimodal Large Language Model for image descriptions.

Key changes:

- The `MarkItDown` class now accepts an `llm_describber` function in its constructor. This callback is propagated to all relevant converters.
- The `ImageConverter`, `PptxConverter`, and `llm_caption` function have been updated to prioritize the `llm_describber` callback if provided, while maintaining backward compatibility with the existing `llm_client` and `llm_model` implementation.
- A new test file, `test_llm_describber.py`, has been added to verify that the `llm_describber` is correctly called.
- The `README.md` file has been updated to document the new `llm_describber` functionality with an example.
@Jhonnyr97
Copy link
Author

@microsoft-github-policy-service agree

@Jhonnyr97
Copy link
Author

@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

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.

1 participant