Skip to main content

Context Layer SDK - versioned context infrastructure for AI apps

Project description

Context Layer

Python SDK for ContextLayer - versioned context infrastructure for AI apps.

Installation

pip install layer-context

For client-side encryption (optional):

pip install layer-context cryptography

Quick Start

from layer_context import CL

cl = CL(api_key="cl_sk_your_key_here")

# Create a block
cl.create_block("system-prompt")

# Get a block handle
block = cl.block("system-prompt")

# Append context
block.append("You are a helpful assistant.")
block.append("Always respond in markdown.")

# Get compiled context
print(block.get_context())
# Output: "You are a helpful assistant.\nAlways respond in markdown."

# Update (replace entire context)
block.update("You are a coding assistant. Use Python examples.")

# Delete specific content
block.delete("Use Python examples.")

# Read updated context
print(block.get_context())
# Output: "You are a coding assistant."

# Create a new version
block.create_version()

# Work with specific versions
block.append("V2 content", version=2)
print(block.get_context(version=2))

# View history
entries = block.get_history()

# List all blocks
blocks = cl.list_blocks()

Client-Side Encryption

Enable zero-knowledge encryption so your context is encrypted before it leaves your machine:

cl = CL(
    api_key="cl_sk_your_key_here",
    encryption_key="my-secret-passphrase"
)

block = cl.block("private-data")
block.append("Sensitive context here")

# Data is stored encrypted on the server
# Only you can read it with the same encryption_key
print(block.get_context())  # Decrypted automatically

Note: Requires pip install cryptography. The server never sees your plaintext data.

License

MIT

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

layer_context-0.1.4.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

layer_context-0.1.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file layer_context-0.1.4.tar.gz.

File metadata

  • Download URL: layer_context-0.1.4.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for layer_context-0.1.4.tar.gz
Algorithm Hash digest
SHA256 23e1ce50fb19b07f101898331aad10c47650b9920541df567451a124c0ec600a
MD5 e6616670dad6db294fd994814fc34f1e
BLAKE2b-256 9749a7855fdcf7973d1c02ffa4484ab3d71f76cd7d815ff08556906a5ac353b7

See more details on using hashes here.

File details

Details for the file layer_context-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: layer_context-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for layer_context-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 09933bb1f784b0c90f2fe746603d22924eb06f8b341d075508ff344855d2f489
MD5 414e41d35ba23230dc0232b6f58ebdc3
BLAKE2b-256 aa1f057d42c88883bd6e40357141be1b03ae9b68c178d841cf98a3c4484e9932

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