mirror of
https://github.com/kennethreitz/langchain.git
synced 2026-06-05 23:00:18 +00:00
Update MongoDBChatMessageHistory to create an index on SessionId (#5632)
All the queries to the database are done based on the SessionId property, this will optimize how Mongo retrieves all messages from a session #### Who can review? Tag maintainers/contributors who might be interested: @dev2049
This commit is contained in:
@@ -47,6 +47,7 @@ class MongoDBChatMessageHistory(BaseChatMessageHistory):
|
||||
|
||||
self.db = self.client[database_name]
|
||||
self.collection = self.db[collection_name]
|
||||
self.collection.create_index("SessionId")
|
||||
|
||||
@property
|
||||
def messages(self) -> List[BaseMessage]: # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user