Hammad712 commited on
Commit
c59b861
Β·
1 Parent(s): 4c94669

Updated mongodb

Browse files
Files changed (2) hide show
  1. app/page_speed/config.py +6 -6
  2. app/rag/db.py +39 -39
app/page_speed/config.py CHANGED
@@ -35,18 +35,18 @@ class Settings(BaseSettings):
35
 
36
  @property
37
  def mongo_uri(self) -> str:
38
- # pw = quote_plus(self.mongo_password)
39
- # return (
40
- # f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/"
41
- # f"{self.mongo_db}?retryWrites=true&w=majority&ssl=true"
42
- # )
43
 
44
 
45
  # ───────────────────────────────────────────────────────────────────────────
46
  # local MongoDB Connection
47
  # ───────────────────────────────────────────────────────────────────────────
48
 
49
- return f"mongodb://localhost:27017/{self.mongo_db}"
50
 
51
 
52
  # ───────────────────────────────────────────────────────────────────────────
 
35
 
36
  @property
37
  def mongo_uri(self) -> str:
38
+ pw = quote_plus(self.mongo_password)
39
+ return (
40
+ f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/"
41
+ f"{self.mongo_db}?retryWrites=true&w=majority&ssl=true"
42
+ )
43
 
44
 
45
  # ───────────────────────────────────────────────────────────────────────────
46
  # local MongoDB Connection
47
  # ───────────────────────────────────────────────────────────────────────────
48
 
49
+ # return f"mongodb://localhost:27017/{self.mongo_db}"
50
 
51
 
52
  # ───────────────────────────────────────────────────────────────────────────
app/rag/db.py CHANGED
@@ -1,50 +1,22 @@
1
- # # db.py
2
- # from pymongo import MongoClient
3
- # from app.page_speed.config import settings
4
- #from qdrant_client import QdrantClient
5
-
6
- # # ──────────────────────────────────────────────────────────────────────────────
7
- # # MongoDB Initialization
8
- # # ──────────────────────────────────────────────────────────────────────────────
9
-
10
- # # Connect to MongoDB using the URI from settings
11
- # mongo_client = MongoClient(settings.mongo_uri)
12
-
13
- # # Use the renamed settings attributes
14
- # mongo_db = mongo_client[settings.mongo_db]
15
-
16
- # # Collection to store metadata that maps user_id β†’ vectorstore_path
17
- # vectorstore_meta_coll = mongo_db["vectorstore_metadata"]
18
-
19
- # # Name of the collection that MongoDBChatMessageHistory will write to
20
- # chat_collection_name = settings.mongo_collection
21
-
22
- # # ─────────────────────────────────────────────
23
- # # Qdrant Setup
24
- # # ─────────────────────────────────────────────
25
- # # If Qdrant is running locally
26
- # qdrant_client = QdrantClient(
27
- # url=settings.qdrant_url, # e.g. "http://localhost:6333"
28
- # api_key=settings.qdrant_api_key or None
29
- # )
30
-
31
- # ____________________________________________________________
32
- #Local MongoDB Connection
33
- # ____________________________________________________________
34
-
35
  # db.py
36
  from pymongo import MongoClient
37
  from app.page_speed.config import settings
38
  from qdrant_client import QdrantClient
39
 
40
- # Always connect to local MongoDB
41
- mongo_client = MongoClient("mongodb://localhost:27017/")
 
42
 
43
- # Select the database from settings
 
 
 
44
  mongo_db = mongo_client[settings.mongo_db]
45
 
46
- # Collections
47
  vectorstore_meta_coll = mongo_db["vectorstore_metadata"]
 
 
48
  chat_collection_name = settings.mongo_collection
49
 
50
  # ─────────────────────────────────────────────
@@ -54,4 +26,32 @@ chat_collection_name = settings.mongo_collection
54
  qdrant_client = QdrantClient(
55
  url=settings.qdrant_url, # e.g. "http://localhost:6333"
56
  api_key=settings.qdrant_api_key or None
57
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # db.py
2
  from pymongo import MongoClient
3
  from app.page_speed.config import settings
4
  from qdrant_client import QdrantClient
5
 
6
+ # ──────────────────────────────────────────────────────────────────────────────
7
+ # MongoDB Initialization
8
+ # ──────────────────────────────────────────────────────────────────────────────
9
 
10
+ # Connect to MongoDB using the URI from settings
11
+ mongo_client = MongoClient(settings.mongo_uri)
12
+
13
+ # Use the renamed settings attributes
14
  mongo_db = mongo_client[settings.mongo_db]
15
 
16
+ # Collection to store metadata that maps user_id β†’ vectorstore_path
17
  vectorstore_meta_coll = mongo_db["vectorstore_metadata"]
18
+
19
+ # Name of the collection that MongoDBChatMessageHistory will write to
20
  chat_collection_name = settings.mongo_collection
21
 
22
  # ─────────────────────────────────────────────
 
26
  qdrant_client = QdrantClient(
27
  url=settings.qdrant_url, # e.g. "http://localhost:6333"
28
  api_key=settings.qdrant_api_key or None
29
+ )
30
+
31
+ # # ____________________________________________________________
32
+ # #Local MongoDB Connection
33
+ # # ____________________________________________________________
34
+
35
+ # # db.py
36
+ # from pymongo import MongoClient
37
+ # from app.page_speed.config import settings
38
+ # from qdrant_client import QdrantClient
39
+
40
+ # # Always connect to local MongoDB
41
+ # mongo_client = MongoClient("mongodb://localhost:27017/")
42
+
43
+ # # Select the database from settings
44
+ # mongo_db = mongo_client[settings.mongo_db]
45
+
46
+ # # Collections
47
+ # vectorstore_meta_coll = mongo_db["vectorstore_metadata"]
48
+ # chat_collection_name = settings.mongo_collection
49
+
50
+ # # ─────────────────────────────────────────────
51
+ # # Qdrant Setup
52
+ # # ─────────────────────────────────────────────
53
+ # # If Qdrant is running locally
54
+ # qdrant_client = QdrantClient(
55
+ # url=settings.qdrant_url, # e.g. "http://localhost:6333"
56
+ # api_key=settings.qdrant_api_key or None
57
+ # )