Download tools/document.py from seanpedrickcase/Light-PDF-Web-QA-Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 500 Bytes
-
https://huggingface.co/spaces/seanpedrickcase/Light-PDF-Web-QA-Chatbot/resolve/main/tools/document.py
- Command line
-
hf download hf://spaces/seanpedrickcase/Light-PDF-Web-QA-Chatbot/tools/document.py
-
curl -L -o document.py https://huggingface.co/spaces/seanpedrickcase/Light-PDF-Web-QA-Chatbot/resolve/main/tools/document.py
500 Bytes
| """ | |
| Custom Document class to replace langchain Document. | |
| """ | |
| from typing import Any, Dict, Optional | |
| class Document: | |
| """A simple document class with page_content and metadata.""" | |
| def __init__(self, page_content: str, metadata: Optional[Dict[str, Any]] = None): | |
| self.page_content = page_content | |
| self.metadata = metadata if metadata is not None else {} | |
| def __repr__(self): | |
| return f"Document(page_content='{self.page_content[:50]}...', metadata={self.metadata})" | |