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

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1a97bd9ee993ac21a5f104e6860170bda41e08a31630fcfb355a4f98629e1582
MD5 a30a18d529e629cf83d9953570500264
BLAKE2b-256 e36cc80e342b24d3d62e41485c99f5a7eaac59d8e0f35d71f67be9656bb6609d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61f0ff6f63ece1d7dafc8375bfef4014b9efbbced601d976c434048bea52c9a2
MD5 e4fdcf57c19d330951f21aceddd15722
BLAKE2b-256 b5a61b32d2c7434673a126ba9ba2e901258cdaaa390ac3855f9a9bd4d7c3701a

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