Skip to content

Commit

Permalink
feat: add retry on pypdf (#12848)
Browse files Browse the repository at this point in the history
* feat: add retry on pypdf

* chore: correct version

* chore: remove exponential
  • Loading branch information
EmanuelCampos authored Apr 15, 2024
1 parent 4127b39 commit ce59634
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
from pathlib import Path
from typing import Any, Dict, List, Optional

from tenacity import retry, stop_after_attempt

from fsspec import AbstractFileSystem

from llama_index.core.readers.base import BaseReader
from llama_index.core.readers.file.base import get_default_fs, is_default_fs
from llama_index.core.schema import Document

logger = logging.getLogger(__name__)

RETRY_TIMES = 3


class PDFReader(BaseReader):
"""PDF parser."""
Expand All @@ -28,6 +33,9 @@ def __init__(self, return_full_document: Optional[bool] = False) -> None:
"""
self.return_full_document = return_full_document

@retry(
stop=stop_after_attempt(RETRY_TIMES),
)
def load_data(
self,
file: Path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ license = "MIT"
maintainers = ["FarisHijazi", "Haowjy", "ephe-meral", "hursh-desai", "iamarunbrahma", "jon-chuang", "mmaatouk", "ravi03071991", "sangwongenip", "thejessezhang"]
name = "llama-index-readers-file"
readme = "README.md"
version = "0.1.18"
version = "0.1.19"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
Expand Down

0 comments on commit ce59634

Please sign in to comment.