chatbot_platform / app /config.py
vip11017's picture
updated production code and addedx mongodb functions
b9b1114
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi
from qdrant_client import QdrantClient
from qdrant_client import QdrantClient
import os
from dotenv import load_dotenv
load_dotenv()
# MongoDB connection
MONGODB_CONNECTION_STRING = os.getenv("MONGODB_CONNECTION_STRING")
DB_NAME = "chatbot_demo"
# Demo chatbot defaults
DEMO_MAX_MESSAGES = 20
DEMO_EXPIRY_DAYS = 7
# Create a new client and connect to the server
client = MongoClient(MONGODB_CONNECTION_STRING, server_api=ServerApi('1'))
# Send a ping to confirm a successful connection
try:
client.admin.command('ping')
print("Pinged your deployment. You successfully connected to MongoDB!")
demo_database = client["Demo"]
chatbot_database = client['Chatbot']
logs_databse = client["Logs"]
demo_form_submissions = demo_database["demo_form_submissions"]
demo_chatbot_configs = demo_database["demo_chatbot_config"]
prod_chatbot_configs = chatbot_database['rag_configs']
admin_database = client["AdminLogs"]
chat_logs = logs_databse["ChatLogs"]
print("Connected to MongoDB collection successfully!")
except Exception as e:
print(e)
#Qdrant
QDRANT_URL = os.getenv("QDRANT_URL")
QDRANT_API_KEY = os.getenv("QDRANT_API_KEY")
qdrant_client = QdrantClient(url=QDRANT_URL, api_key=QDRANT_API_KEY)
embedding_model = "intfloat/e5-base-v2"