Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

change insert_one() to insert_many() in mongo_db save function. #455

Merged
merged 15 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions RAGchain/DB/mongo_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ def create_or_load(self):

def save(self, passages: List[Passage]):
"""Saves the passages to MongoDB collection."""
dict_passages = []
id_list = []
db_origin_list = []
for passage in passages:
# save to mongoDB
passage_to_dict = passage.to_dict()
self.collection.insert_one(passage_to_dict)
# save to redisDB
# Setting up files for saving to 'mongodb'
dict_passages.append(passage.to_dict())
# Setting up files for saving to 'linker'
db_origin = self.get_db_origin()
db_origin_dict = db_origin.to_dict()
id_list.append(str(passage.id))
db_origin_list.append(db_origin_dict)
# save to 'mongodb'
self.collection.insert_many(dict_passages)
# save to 'linker'
linker.put_json(id_list, db_origin_list)

def fetch(self, ids: List[UUID]) -> List[Passage]:
Expand Down
2 changes: 1 addition & 1 deletion RAGchain/DB/pickle_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def save(self, passages: List[Passage]):
# save to pickleDB
self.db.extend(passages)
self._write_pickle()
# save to redisDB
# save to linker
db_origin = self.get_db_origin()
db_origin_dict = db_origin.to_dict()
id_list = []
Expand Down