Python tool for converting files and office documents to Markdown.
Merge main.
Adam Fourney95188a4a27cc
diff --cc tests/test_markitdown.pyindex f2348a11,bfc316cc..7db904d5--- a/tests/test_markitdown.py+++ b/tests/test_markitdown.py@@@ -231,43 -243,28 +245,63 @@@ def test_markitdown_exiftool() -> Noneassert target in result.text_content+def test_markitdown_deprecation() -> None:+ try:+ with catch_warnings(record=True) as w:+ test_client = object()+ markitdown = MarkItDown(mlm_client=test_client)+ assert len(w) == 1+ assert w[0].category is DeprecationWarning+ assert markitdown._llm_client == test_client+ finally:+ resetwarnings()++ try:+ with catch_warnings(record=True) as w:+ markitdown = MarkItDown(mlm_model="gpt-4o")+ assert len(w) == 1+ assert w[0].category is DeprecationWarning+ assert markitdown._llm_model == "gpt-4o"+ finally:+ resetwarnings()++ try:+ test_client = object()+ markitdown = MarkItDown(mlm_client=test_client, llm_client=test_client)+ assert False+ except ValueError:+ pass++ try:+ markitdown = MarkItDown(mlm_model="gpt-4o", llm_model="gpt-4o")+ assert False+ except ValueError:+ pass+++ @pytest.mark.skipif(+ skip_llm,+ reason="do not run llm tests without a key",+ )+ def test_markitdown_llm() -> None:+ client = openai.OpenAI()+ markitdown = MarkItDown(llm_client=client, llm_model="gpt-4o")++ result = markitdown.convert(os.path.join(TEST_FILES_DIR, "test_llm.jpg"))++ for test_string in LLM_TEST_STRINGS:+ assert test_string in result.text_content++ # This is not super precise. It would also accept "red square", "blue circle",+ # "the square is not blue", etc. But it's sufficient for this test.+ for test_string in ["red", "circle", "blue", "square"]:+ assert test_string in result.text_content.lower()++if __name__ == "__main__":"""Runs this file's tests from the command line."""test_markitdown_remote()test_markitdown_local()test_markitdown_exiftool()+ test_markitdown_deprecation()+ test_markitdown_llm()