Skip to main content

llama-index storage-chat-store upstash integration

Project description

LlamaIndex Chat_Store Integration: Upstash Chat Store

Installation

pip install llama-index-storage-chat-store-upstash

Usage

from llama_index.storage.chat_store.upstash import UpstashChatStore
from llama_index.core.memory import ChatMemoryBuffer

chat_store = UpstashChatStore(
    redis_url="YOUR_UPSTASH_REDIS_URL",
    redis_token="YOUR_UPSTASH_REDIS_TOKEN",
    ttl=300,  # Optional: Time to live in seconds
)

chat_memory = ChatMemoryBuffer.from_defaults(
    token_limit=3000,
    chat_store=chat_store,
    chat_store_key="user1",
)

UpstashChatStore supports both synchronous and asynchronous operations. Here's an example of using async methods:

import asyncio
from llama_index.core.llms import ChatMessage


async def main():
    # Add messages
    messages = [
        ChatMessage(content="Hello", role="user"),
        ChatMessage(content="Hi there!", role="assistant"),
    ]
    await chat_store.async_set_messages("conversation1", messages)

    # Retrieve messages
    retrieved_messages = await chat_store.async_get_messages("conversation1")
    print(retrieved_messages)

    # Delete last message
    deleted_message = await chat_store.async_delete_last_message(
        "conversation1"
    )
    print(f"Deleted message: {deleted_message}")


asyncio.run(main())

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

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_upstash-0.3.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.3.1.tar.gz
Algorithm Hash digest
SHA256 472c637a1108595260cab13d11f2c64afeb0a20610ffa570557a3c9f7593d238
MD5 0cf4c61a9aebe3abf01ae1e6c92cbc85
BLAKE2b-256 42893efac397d06b53aa03ae8747e18ce1a5524208d2ed61f08f408b57b62413

See more details on using hashes here.

File details

Details for the file llama_index_storage_chat_store_upstash-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbded58b5f847342446ed18fd59730664ef19e06a626b8ecc57bc958d1480ccd
MD5 12ca6adfc8a890173645bd2ad34042da
BLAKE2b-256 11fa63d39b8a107be82a1cfc2a74286cc8c1d501edb02bf5eeb33f9869dd8911

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