Skip to content

Commit

Permalink
do not attach a filepath when a stram of bytes is passed (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
hexapode authored Sep 10, 2024
1 parent 7cb6d06 commit bbbae9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions llama_parse/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,13 @@ async def _aget_json(
job_id = await self._create_job(file_path, extra_info=extra_info)
if self.verbose:
print("Started parsing the file under job_id %s" % job_id)

result = await self._get_job_result(job_id, "json")
result["job_id"] = job_id
result["file_path"] = file_path
return [result]

if not isinstance(file_path, (bytes, BufferedIOBase)):
result["file_path"] = str(file_path)

return [result]
except Exception as e:
file_repr = file_path if isinstance(file_path, str) else "<bytes/buffer>"
print(f"Error while parsing the file '{file_repr}':", e)
Expand Down Expand Up @@ -506,7 +507,9 @@ async def aget_images(

image["path"] = image_path
image["job_id"] = job_id
image["original_pdf_path"] = result["file_path"]

image["original_file_path"] = result.get("file_path", None)

image["page_number"] = page["page"]
with open(image_path, "wb") as f:
image_url = f"{self.base_url}/api/parsing/job/{job_id}/result/image/{image_name}"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "llama-parse"
version = "0.5.4"
version = "0.5.5"
description = "Parse files into RAG-Optimized formats."
authors = ["Logan Markewich <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit bbbae9d

Please sign in to comment.