LLaMAIndexSemanticCacheWrite
Python template · sinapsis_llama_index.templates.llama_index_semantic_cache_write
Overview
Write completed LLM responses into a PGVector-backed semantic cache.
This template stores one semantic cache entry per completed `LLMConversationPacket`. The user prompt is embedded as the vector-search key, while the cached response and exact-match request hashes are stored in the node metadata.
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-llama-index==1.0.0uv pip install sinapsis-llama-index==1.0.0uv add sinapsis-llama-index==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
PGVector connection settings.
Optional
Default: null
Database host address (hostname or IP). Loaded from PGVECTOR_HOST if not provided. Defaults to `"localhost"`.
Optional
Default: "localhost"
Database port number. Loaded from PGVECTOR_PORT if not provided. Defaults to `5432`.
Optional
Default: 5432
Database user name. Loaded from PGVECTOR_USER if not provided. Defaults to `None`.
Optional
Default: null
Name of the specific database to connect to. Defaults to `"sinapsis_db"`.
Optional
Default: "sinapsis_db"
Database password. Loaded from PGVECTOR_PASSWORD if not provided. Defaults to `None`.
Optional
Default: null
Database provider. Supabase uses the existing database and SSL. Defaults to `"postgres"`.
Optional
Default: "postgres"
Name of the table within the database containing the vectors. Defaults to `"sinapsis_table"`.
Optional
Default: "sinapsis_table"
When `True`, omit `user_id` and `session_id` from stored metadata.
Optional
Default: false
Embedding model used to encode the prompt.
Required
Default: null
The device to run the model on ('cuda', 'cpu', 'auto'). If 'auto', selects 'cuda' if available, otherwise 'cpu'. Defaults to `"auto"`.
Optional
Default: "auto"
Whether to normalize the embeddings. Defaults to `True`.
Optional
Default: true
Maximum sequence length for the model. Usually inferred if None. Defaults to `None`.
Optional
Default: null
The name or path of the HuggingFace embedding model (e.g., 'BAAI/bge-small-en-v1.5').
Required
Default: null
Path to cache directory for downloading/loading models. Defaults to `SINAPSIS_CACHE_DIR`.
Optional
Default: "/home/ariel/.cache/sinapsis"
Batch size for embedding generation. Defaults to `DEFAULT_EMBED_BATCH_SIZE`.
Optional
Default: 10
Whether to use parallel processing if multiple GPUs are available. Defaults to `False`.
Optional
Default: false
Instruction prefix for document embeddings (e.g., for Instructor models). Defaults to `None`.
Optional
Default: null
Instruction prefix for query embeddings (e.g., for Instructor models). Defaults to `None`.
Optional
Default: null
Allow execution of remote code for custom models. Defaults to `False`.
Optional
Default: false
Configuration example
Example from the Python docstring:
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: LLaMAIndexSemanticCacheWrite
class_name: LLaMAIndexSemanticCacheWrite
template_input: InputTemplate
attributes:
embedding_config:
model_name: nomic-ai/nomic-embed-text-v1.5
trust_remote_code: true
device: cpu
db_config:
user: my_user
password: my_password
db_name: my_db
table_name: semantic_cache
global_scope: falseShow schema-based configuration skeleton
templates:
- template_name: "LLaMAIndexSemanticCacheWrite"
class_name: "LLaMAIndexSemanticCacheWrite"
attributes:
db_config:
host: "localhost"
port: 5432
user: null
db_name: "sinapsis_db"
password: null
provider: "postgres"
table_name: "sinapsis_table"
global_scope: false
embedding_config:
device: "auto"
normalize: true
max_length: null
model_name: "<required>"
cache_folder: "/home/ariel/.cache/sinapsis"
embed_batch_size: 10
parallel_process: false
text_instruction: null
query_instruction: null
trust_remote_code: false
Inheritance
sinapsis_core.template_base.template.TemplateEnvironment variables
Environment definitions belong to their canonical Python modules.
No directly related environment variables listed.