Skip to content

Commit

Permalink
Fix file path resolution from load_document
Browse files Browse the repository at this point in the history
  • Loading branch information
PSU3D0 committed Aug 3, 2024
1 parent 3395c61 commit a4af814
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docprompt/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,18 @@ def load_pdf_document(
if isinstance(fp, bytes):
file_bytes = fp
file_name = file_name or determine_pdf_name_from_bytes(file_bytes)
file_path = None
else:
file_name = name_from_path(fp) if file_name is None else file_name

file_path = str(fp)
file_bytes = read_pdf_bytes_from_path(fp)

if not is_pdf(file_bytes):
raise ValueError("File is not a PDF")

return PdfDocument(
name=unquote(file_name),
file_path=str(fp),
file_path=file_path,
file_bytes=file_bytes,
password=password,
)
Expand Down

0 comments on commit a4af814

Please sign in to comment.