mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 00:48:45 +00:00
Refining Skip Count Calculation by Filtering Documents with session_id
(#26020)
In the previous implementation, `skip_count` was counting all the documents in the collection. Instead, we want to filter the documents by `session_id` and calculate `skip_count` by subtracting `history_size` from the filtered count. --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
parent
a8b24135a2
commit
c6c508ee96
@ -122,7 +122,11 @@ class MongoDBChatMessageHistory(BaseChatMessageHistory):
|
||||
cursor = self.collection.find({self.session_id_key: self.session_id})
|
||||
else:
|
||||
skip_count = max(
|
||||
0, self.collection.count_documents({}) - self.history_size
|
||||
0,
|
||||
self.collection.count_documents(
|
||||
{self.session_id_key: self.session_id}
|
||||
)
|
||||
- self.history_size,
|
||||
)
|
||||
cursor = self.collection.find(
|
||||
{self.session_id_key: self.session_id}, skip=skip_count
|
||||
|
Loading…
Reference in New Issue
Block a user