llama-index storage-chat-store mongo integration
Project description
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 AsyncIOMotorClient and a database name and collection name.
from pymongo import MongoClient
from motor.motor_asyncio import AsyncIOMotorClient
client = MongoClient("mongodb://localhost:27017/")
async_client = AsyncIOMotorClient("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 AsyncIOMotorCollection.
from pymongo import Collection
from motor.motor_asyncio import AsyncIOMotorCollection
client = MongoClient("mongodb://localhost:27017/")
async_client = AsyncIOMotorClient("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",
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_storage_chat_store_mongo-0.2.0.tar.gz.
File metadata
- Download URL: llama_index_storage_chat_store_mongo-0.2.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
510ddd30ae335a849836bf047f974796c306a6f7599c14b236c55aa127080876
|
|
| MD5 |
0a1df17c2d0f2d7f4176b24b18000e3d
|
|
| BLAKE2b-256 |
a6cd4a7d4ab6d5d6163069fdc4f9007ecc125c322a65d5fd9db7b931b74b0b0e
|
File details
Details for the file llama_index_storage_chat_store_mongo-0.2.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_storage_chat_store_mongo-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
532031f384948f5f05ba77d78740188a228ab5fe2a167038b7a318f931960384
|
|
| MD5 |
c70f6743f6cd4cf08a8fb0554de6dea7
|
|
| BLAKE2b-256 |
4b752ed62d3b77df19ea564b502bb440997a0be98590e3accb7bf8f51f2a76d5
|