Spaces:
Sleeping
Sleeping
File size: 1,181 Bytes
f3aae92 e9fe174 f3aae92 e9fe174 f3aae92 e9fe174 f3aae92 e9fe174 f3aae92 e9fe174 f3aae92 e9fe174 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import os
from dotenv import load_dotenv
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi
load_dotenv()
client = None
def get_mongo_client() -> MongoClient:
global client
if client is None:
password = os.getenv("PASSWORD")
uri = f"mongodb+srv://DDR:{password}@cluster0.o7h6s.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0"
client = MongoClient(uri, server_api=ServerApi('1'), uuidRepresentation='standard')
try:
client.admin.command('ping')
print("Pinged your deployment. You successfully connected to MongoDB!")
except Exception as e:
print(e)
return client
# Max concurrency used for extracting content from documents.
# A long document is broken into smaller chunks this controls
# how many chunks are processed concurrently.
MAX_CONCURRENCY = int(os.getenv("MAX_CONCURRENCY", 1))
# Max number of chunks to process per documents
# When a long document is split into chunks, this controls
# how many of those chunks will be processed.
# Set to 0 or negative to disable the max chunks limit.
MAX_CHUNKS = int(os.getenv("MAX_CHUNKS", -1))
|