Skip to content

Commit 9dbf3e6

Browse files
committed
[PDFMardownReader] Cleaned code
1 parent 90fa4fb commit 9dbf3e6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

pymupdf4llm/pymupdf4llm/llama_index/pdf_markdown_reader.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
from pathlib import Path
33
from typing import Any, Callable, Dict, List, Optional, Union
44

5+
import fitz
6+
from fitz import Document as FitzDocument
7+
58
try:
6-
import fitz
7-
from fitz import Document as FitzDocument
89
from llama_index.core.readers.base import BaseReader
910
from llama_index.core.schema import Document as LlamaIndexDocument
1011

1112
print("All imports are successful.")
1213
except ImportError:
13-
raise NotImplementedError(
14-
"Please install 'llama_index' version 1.24.0 or later is needed."
15-
)
14+
raise NotImplementedError("Please install 'llama_index' is needed.")
1615

1716

1817
import pymupdf4llm

tests/pymupdf4llm/llama_index/test_pdf_markdown_reader.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import os
22

33
import pytest
4-
from gary.services.rag.reader.pdf import LlamaIndexDocument
4+
from llama_index.core.schema import Document as LlamaIndexDocument
55

6-
from pymupdf4llm.pymupdf4llm.llama_index.pdf_markdown_reader import PDFMardownReader
6+
try:
7+
from llama_index.core.readers.base import BaseReader
8+
from llama_index.core.schema import Document as LlamaIndexDocument
9+
10+
print("All imports are successful.")
11+
except ImportError:
12+
raise NotImplementedError("Please install 'llama_index' is needed.")
713

8-
# Temporay.
14+
15+
from pymupdf4llm.pymupdf4llm.llama_index.pdf_markdown_reader import PDFMardownReader
916

1017
PDF = "input.pdf"
1118

0 commit comments

Comments
 (0)