Spaces:
Runtime error
Runtime error
Download src/config/_database.py from sifars/keepme-backend: direct link, hf CLI and curl.
- Browser
- Download file 782 Bytes
-
https://huggingface.co/spaces/sifars/keepme-backend/resolve/main/src/config/_database.py
- Command line
-
hf download hf://spaces/sifars/keepme-backend/src/config/_database.py
-
curl -L -o _database.py https://huggingface.co/spaces/sifars/keepme-backend/resolve/main/src/config/_database.py
782 Bytes
| import os | |
| from beanie import init_beanie | |
| from motor.motor_asyncio import AsyncIOMotorClient | |
| from src.models import User, Session, File, VectorStoreRecordId, Conversation, Message | |
| class DatabaseConfig: | |
| def __init__(self): | |
| self.MONGO_URI = os.getenv("MONGO_DB_URI") | |
| self.MONGO_DB_NAME = os.getenv("MONGO_DB_NAME") | |
| self.client = AsyncIOMotorClient(self.MONGO_URI, uuidRepresentation="standard") | |
| self.db = self.client[self.MONGO_DB_NAME] | |
| async def init_beanie(self): | |
| await init_beanie( | |
| database=self.db, | |
| document_models=[ | |
| User, | |
| Session, | |
| Conversation, | |
| Message, | |
| File, | |
| VectorStoreRecordId, | |
| ], | |
| ) | |