MongoDBHandshake class provides integration between Chonkie’s chunking system and MongoDB, a popular NoSQL database.
Embed and store your Chonkie chunks in MongoDB directly from the Chonkie SDK.
Installation
Before using the MongoDB handshake, make sure to install the required dependencies:Initialization
Parameters
MongoDB client instance. If not provided, a new client will be created based on other parameters.
MongoDB connection URI.
MongoDB username for authentication.
MongoDB password for authentication.
MongoDB host address.
MongoDB port number.
Name of the database to use. If “random”, a unique name will be generated.
Name of the collection to use. If “random”, a unique name will be generated.
Embedding model to use. Can be a model name or a BaseEmbeddings instance.
Additional keyword arguments to pass to the MongoDB client or collection creation.
Writing Chunks to MongoDB
Searching Chunks in MongoDB
You can retrieve the most similar chunks from your MongoDB collection using thesearch method:
