Spaces:
Runtime error
Runtime error
Download src/utils/data_ingestion_utils.py from RDeepak/RAG-Embedding-Search-EPs: direct link, hf CLI and curl.
- Browser
- Download file 647 Bytes
-
https://huggingface.co/spaces/RDeepak/RAG-Embedding-Search-EPs/resolve/main/src/utils/data_ingestion_utils.py
- Command line
-
hf download hf://spaces/RDeepak/RAG-Embedding-Search-EPs/src/utils/data_ingestion_utils.py
-
curl -L -o data_ingestion_utils.py https://huggingface.co/spaces/RDeepak/RAG-Embedding-Search-EPs/resolve/main/src/utils/data_ingestion_utils.py
647 Bytes
| import os | |
| import sys | |
| from dotenv import load_dotenv | |
| from pymongo.mongo_client import MongoClient | |
| from pymongo.server_api import ServerApi | |
| from src.exception import CustomException | |
| load_dotenv() | |
| uri = os.getenv('CLUSTER_URI') | |
| try: | |
| client = MongoClient(uri, server_api=ServerApi('1')) | |
| client.admin.command('ping') | |
| except Exception as e: | |
| raise CustomException(e, sys) | |
| def dataloader(db, collection, query={}, proj={}): | |
| db = client[db] | |
| collection = db[collection] | |
| try: | |
| records = collection.find(query, proj) | |
| return records | |
| except Exception as e: | |
| raise CustomException(e, sys) | |