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

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8ac58db27aa11dfb937c1d092ece435d07a257fd452799d3574e8733ccf1be80
MD5 bd97bbc6f42e879d3a0f420feccbd87a
BLAKE2b-256 119d2981f170bc44d5c749b5aeb6219990a9483435ef3f32041a9cc882458a17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_storage_chat_store_upstash-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3df7b15256f2d04117246cf50b993808d65fd3c9049682ec31629108aa41f889
MD5 6b4bbd7e56df1130a0f3c697de15c23a
BLAKE2b-256 0046f111c041535b0dd66c24f447e00a898f4ed4ebb965d077954f4d31995cde

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