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.1.2.tar.gz.

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7d2b927155658e682724b7d70be09c0c26692640d92bd60965548c3cb3e0b336
MD5 95081cfddfc4d4aab44be3d324e6ad6a
BLAKE2b-256 226d10d49e12f36502f253f2414ee65a5e6f1601efc16700dab82e68c2b76622

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 10cd726f18df551d2151bc0d65479ca6580c037012c13794b98a37227d5cd401
MD5 adfb1a8459d4560c585a59194bdd5892
BLAKE2b-256 30e1144deda0c646db28eb585f3efa1c3ada62c46cfe48083a123d4bd1c6e336

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