Skip to content

Commit

Permalink
Update README.md to convey need to specify extra_info["file_name"] (#417
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sourabhdesai authored Sep 30, 2024
1 parent c139e8e commit 2ccd2a9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ parser = LlamaParse(
language="en", # Optionally you can define a language, default=en
)

with open("./my_file1.pdf", "rb") as f:
documents = parser.load_data(f)
file_name = "my_file1.pdf"
extra_info = {"file_name": file_name}

with open(f"./{file_name}", "rb") as f:
# must provide extra_info with file_name key with passing file object
documents = parser.load_data(f, extra_info=extra_info)

# you can also pass file bytes directly
with open("./my_file1.pdf", "rb") as f:
with open(f"./{file_name}", "rb") as f:
file_bytes = f.read()
documents = parser.load_data(file_bytes)
# must provide extra_info with file_name key with passing file bytes
documents = parser.load_data(file_bytes, extra_info=extra_info)
```

## Using with `SimpleDirectoryReader`
Expand Down

0 comments on commit 2ccd2a9

Please sign in to comment.