LlamaIndex Chat Store Integration: MongoDB Chat Store
Installation
pip install llama-index-storage-chat-store-mongodb
Usage
Using MongoChatStore from llama_index.storage.chat_store.mongo
you can store chat history in MongoDB.
from llama_index.storage.chat_store.mongo import MongoChatStore
# Initialize the MongoDB chat store with URI and database name and collection name
chat_store = MongoChatStore(
mongodb_uri="mongodb://localhost:27017/",
db_name="llama_index",
collection_name="chat_sessions",
)
You can also initialize the chat store with a MongoClient or AsyncMongoClient and a database name and collection name.
from pymongo import MongoClient, AsyncMongoClient
client = MongoClient("mongodb://localhost:27017/")
async_client = AsyncMongoClient("mongodb://localhost:27017/")
chat_store = MongoChatStore(
client=client,
amongo_client=async_client,
db_name="llama_index",
collection_name="chat_sessions",
)
You can also initialize the chat store with a Collection or AsyncCollection.
from pymongo import Collection
from pymongo.asynchronous import AsyncCollection
client = MongoClient("mongodb://localhost:27017/")
async_client = AsyncMongoClient("mongodb://localhost:27017/")
collection = client["llama_index"]["chat_sessions"]
async_collection = async_client["llama_index"]["chat_sessions"]
chat_store = MongoChatStore(
collection=collection, async_collection=async_collection
)
Usage with LlamaIndex
from llama_index.core.chat_engine.types import ChatMessage
chat_memory = ChatMemoryBuffer.from_defaults(
token_limit=3000,
chat_store=chat_store,
chat_store_key="user1",
)
Metadata
Release files for llama-index-storage-chat-store-mongo 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_storage_chat_store_mongo-0.5.0.tar.gz | 5.4 kB | Without provenance | Details for llama_index_storage_chat_store_mongo-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_storage_chat_store_mongo-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_storage_chat_store_mongo-0.5.0-py3-none-any.whl |
Total release size: 10.6 kB
Release files / llama_index_storage_chat_store_mongo-0.5.0.tar.gz
| Download URL | llama_index_storage_chat_store_mongo-0.5.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd92359f6e2510af770411911c1f2a899963204dbbc6db49fcc4a4be75d84e98
|
|
BLAKE2b-256 checksum How to use checksums |
4500288faa500a6c28f7df7120dd29c2fda87c5912d7aa046586a42d92906aea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_storage_chat_store_mongo-0.5.0-py3-none-any.whl
| Download URL | llama_index_storage_chat_store_mongo-0.5.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a8460f7df6f5bbcb85441b2a861b43a8aa3a86f4c2dee9c7d67f507e8e6077c
|
|
BLAKE2b-256 checksum How to use checksums |
95715ad4ebdac50cb5b26e47f1f684b0dad7f83c273449ac7c7baa90ac299e78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-storage-chat-store-mongo 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.