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

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f5cd3e9a96d12cc8592c934fc1c75edf7db1e7f49b582a174af7e43390feed6b
MD5 ea6953a4f59f6c990a30513d7d9efb67
BLAKE2b-256 1f5a7a6b014bc0f263964b15cfc311841f1e9126fe64f3449b7a32f63f7e6a3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99701156e264f558c7e2bd1eb7259dc0b21e90d3a313d387a759c2d84dbd8c92
MD5 33aeea0d98e65feb56972f86a9f91dce
BLAKE2b-256 5e3eab5abc482560bcbcc9154e05a3433e6d49be790f3e212599ce93b35a11ff

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