Key-Value Store

This documentation provides comprehensive guidance on utilizing the key-value store module, essential for developing robust AI applications. This module can be used to perfrom tasks such as:

  • Caching Results: Speed up access to repeated computations or predictions by storing and retrieving from a fast cache.
  • Session Storage: Maintain user session data and preferences in conversational AI and recommendation systems for personalized interactions.
  • Configurations and Settings: Manage dynamic AI model configurations and settings for real-time adaptability and personalization.

This documentation details how to manage and interact with namespaces and key-value pairs effectively. Within Lepton AI, each workspace can have multiple namespaces to store key-value pairs separately. Each namespace can have multiple key-value pairs.

If you are using python SDK, make sure you are logged in via lep login command with the workspace token. You can find it under settings page

List Namespaces

View all available namespaces within your workspace.

from leptonai.kv import KV
# List all namespaces
x = KV.list_kv() # This is not implemented yet

Create Namespace

Create a new namespace for key-value pairs to be stored at.

from leptonai.kv import KV
# create a namespace
x = KV.create_kv("somenamespace")

Delete Namespace

Delete a namespace and its associated data.

from leptonai.kv import KV
# delete a namespace
x = KV.delete_kv("somenamespace") 

Create Key-Value Pair under a Namespace

Add new key-value pairs within a specific namespace.

from leptonai.kv import KV
# retrive a namespace
x = KV.get_kv("somenamespace") 
# insert a key-value pair
x.put('somekey','somevalue')

Get Value of a Key under a Namespace

Retrieve the value associated with a specific key in a namespace.

from leptonai.kv import KV
# retrive a namespace
x = KV.get_kv("somenamespace") 
# retirve the value based on a given key
x.get('somekey')

Delete Key-Value Pair under a Namespace

Remove individual key-value pairs from a namespace, ensuring data relevance and cleanliness.

from leptonai.kv import KV
# retrive a namespace
x = KV.get_kv("somenamespace") 
# remote the key-value pair
x.delete('somekey')