Replies: 1 comment 4 replies
-
To add a custom key-value pair in the existing metadata JSON when running from langchain_community.document_loaders import PDFPlumberLoader
from langchain_core.documents import Document
# Define the metadata extraction function.
def metadata_func(record: Document, metadata: dict) -> dict:
metadata["custom_key"] = "custom_value" # Add your custom key-value pair here
return metadata
# Initialize the loader with the metadata function.
loader = PDFPlumberLoader(file_path, metadata_func=metadata_func)
documents = loader.load()
print(documents[0].metadata) In this example, the |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
How to add a custom key value pair in existing metadata json when running loader.load()
System Info
langchain==0.1.1
langchain-anthropic==0.1.22
langchain-community==0.0.20
langchain-core==0.2.28
langchain-openai==0.0.5
langchainhub==0.1.14
Linux
python==3.12.4
Beta Was this translation helpful? Give feedback.
All reactions