Skip to main content

Configuration

Chengeta AI can be configured programmatically or via environment variables.


ChengetaSettings

The ChengetaSettings dataclass holds all configuration. Use it with CacheManager.from_settings().

from chengeta_ai import CacheManager, ChengetaSettings

# Programmatic configuration
settings = ChengetaSettings(
backend="disk",
disk_path="/data/cache",
default_ttl=3600,
namespace="myapp",
)
manager = CacheManager.from_settings(settings)

All Parameters

ParameterTypeDefaultDescription
backend"memory" | "disk" | "redis""memory"Primary storage backend
redis_urlstr"redis://localhost:6379/0"Redis connection URL
disk_pathstr"/tmp/chengeta"Disk cache directory path
default_ttlint | None3600Default TTL in seconds (None = no expiry)
semantic_thresholdfloat0.95Minimum cosine similarity for semantic cache hit
vector_backend"faiss" | "chroma" | "none""none"Vector similarity backend
embedding_dimint1536Embedding dimension (for FAISS)
max_memory_entriesint10000Max entries for InMemoryBackend
key_hash_algo"sha256" | "md5""sha256"Hash algorithm for key generation
namespacestr"chengeta"Key prefix namespace
ttl_embeddingint | None86400TTL for embedding cache (24h)
ttl_retrievalint | None3600TTL for retrieval cache (1h)
ttl_contextint | None1800TTL for context cache (30min)
ttl_responseint | None600TTL for response cache (10min)

Environment Variables

Every setting maps to an CHENGETA_* environment variable. Load them with ChengetaSettings.from_env().

from chengeta_ai import CacheManager, ChengetaSettings

manager = CacheManager.from_settings(ChengetaSettings.from_env())
VariableDefaultDescription
CHENGETA_BACKENDmemorymemory, disk, or redis
CHENGETA_REDIS_URLredis://localhost:6379/0Redis connection URL
CHENGETA_DISK_PATH/tmp/chengetaDisk cache directory
CHENGETA_DEFAULT_TTL3600Seconds; none = no expiry
CHENGETA_NAMESPACEchengetaKey prefix
CHENGETA_SEMANTIC_THRESHOLD0.95Float 0-1
CHENGETA_VECTOR_BACKENDnonefaiss, chroma, or none
CHENGETA_EMBEDDING_DIM1536Embedding dimension
CHENGETA_MAX_MEMORY_ENTRIES10000InMemoryBackend capacity
CHENGETA_KEY_HASH_ALGOsha256sha256 or md5
CHENGETA_TTL_EMBEDDING86400Per-layer TTL
CHENGETA_TTL_RETRIEVAL3600Per-layer TTL
CHENGETA_TTL_CONTEXT1800Per-layer TTL
CHENGETA_TTL_RESPONSE600Per-layer TTL

Example

export CHENGETA_BACKEND=redis
export CHENGETA_REDIS_URL=redis://cache.internal:6379/0
export CHENGETA_DEFAULT_TTL=7200
export CHENGETA_NAMESPACE=prod
export CHENGETA_TTL_RESPONSE=300