Spaces:
Sleeping
Sleeping
Download python_backend/src/Agents/utils/rag_utils.py from VashuTheGreat2/ML-Learner: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/python_backend/src/Agents/utils/rag_utils.py
- Command line
-
hf download hf://spaces/VashuTheGreat2/ML-Learner/python_backend/src/Agents/utils/rag_utils.py
-
curl -L -o rag_utils.py https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/python_backend/src/Agents/utils/rag_utils.py
690 Bytes
| import logging | |
| from exception import MyException | |
| import sys | |
| import os | |
| from langchain_community.document_loaders import PyPDFLoader | |
| async def document_loader(file_path=""): | |
| logging.info(f"Entering document_loader with file_path: {file_path}") | |
| try: | |
| if not os.path.exists(file_path): | |
| logging.error(f"File not found: {file_path}") | |
| raise FileNotFoundError(f"file not found at location {file_path}") | |
| loader = PyPDFLoader(file_path=file_path) | |
| documents = loader.load() | |
| logging.info(f"Successfully loaded {len(documents)} document pages") | |
| return documents | |
| except Exception as e: | |
| raise MyException(e, sys) |