Spaces:
Sleeping
Sleeping
Download src/agents/metadata_agent.py from NandiniKodali/docpipe: direct link, hf CLI and curl.
- Browser
- Download file 549 Bytes
-
https://huggingface.co/spaces/NandiniKodali/docpipe/resolve/main/src/agents/metadata_agent.py
- Command line
-
hf download hf://spaces/NandiniKodali/docpipe/src/agents/metadata_agent.py
-
curl -L -o metadata_agent.py https://huggingface.co/spaces/NandiniKodali/docpipe/resolve/main/src/agents/metadata_agent.py
549 Bytes
| from pathlib import Path | |
| class MetadataAgent: | |
| def enrich(self, metadata: dict, file_path: Path) -> dict: | |
| m = dict(metadata) | |
| m.setdefault("source_file", str(file_path)) | |
| m.setdefault("file_type", file_path.suffix.lstrip(".")) | |
| m.setdefault("title", file_path.stem) | |
| m.setdefault("author", "") | |
| m.setdefault("creation_date", "") | |
| m.setdefault("page_count", 0) | |
| m["source_file"] = str(Path(m["source_file"]).resolve()) | |
| m["filename"] = Path(m["source_file"]).name | |
| return m | |