Skip to main content

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 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",
)

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

llama_index_storage_chat_store_mongo-0.4.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_storage_chat_store_mongo-0.4.0.tar.gz.

File metadata

  • Download URL: llama_index_storage_chat_store_mongo-0.4.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}

File hashes

Hashes for llama_index_storage_chat_store_mongo-0.4.0.tar.gz
Algorithm Hash digest
SHA256 bdd5bf74c82bcd3a45a14f2e9912115ac2bccca5752f34b63ee625068d9963af
MD5 2afacad713f4899f027f56a197ff7da8
BLAKE2b-256 6a0d9a88d3be2909b54d824a1c69a3f7745e42804859a331445224d2dd340c9d

See more details on using hashes here.

File details

Details for the file llama_index_storage_chat_store_mongo-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_storage_chat_store_mongo-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}

File hashes

Hashes for llama_index_storage_chat_store_mongo-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 287034a69536929e269231f73034b961cd3bab0ca431e58808ea6066c8eea903
MD5 45831da6d57acdc9de00f410f309925b
BLAKE2b-256 b5e88a158e044684b9f80a6ad1685d75e75948d845801784237beeebbcdef4ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page