Spaces:
Sleeping
Sleeping
Download data_loader.py from TharaKavin/Production_Rag: direct link, hf CLI and curl.
- Browser
- Download file 458 Bytes
-
https://huggingface.co/spaces/TharaKavin/Production_Rag/resolve/main/data_loader.py
- Command line
-
hf download hf://spaces/TharaKavin/Production_Rag/data_loader.py
-
curl -L -o data_loader.py https://huggingface.co/spaces/TharaKavin/Production_Rag/resolve/main/data_loader.py
458 Bytes
| import json | |
| from typing import List, Dict, Any | |
| def load_documents(path: str) -> Dict[str, Any]: | |
| with open(path, "r", encoding="utf-8") as f: | |
| data = json.load(f) | |
| return data | |
| def validate_document(data: Dict[str, Any]) -> bool: | |
| required = ["doc_name", "structure"] | |
| for field in required: | |
| if field not in data: | |
| return False | |
| if not isinstance(data.get("structure"), list): | |
| return False | |
| return True | |