LLaMAIndexNodeRetriever
Python template · sinapsis_llama_index.templates.llama_index_node_retriever
Overview
Retrieve relevant nodes from PGVector and attach them to packet state.
This template supports both `TextPacket` and `LLMConversationPacket` inputs. Text queries are written back into `text_packet.generic_data[self.instance_name]`, while LLM queries are written into `llm_conversation.contexts` so downstream LLM templates can consume them directly.
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
Configuration for connecting to the PostgreSQL database, handling credentials via environment variables if needed.
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"
Parameters controlling the retrieval process, such as query mode, top_k results to fetch, and the similarity threshold.
Optional
Default: null
Optional document identifiers to restrict retrieval to. Defaults to `None`.
Optional
Default: null
Optional node identifiers to restrict retrieval to. Defaults to `None`.
Optional
Default: null
The minimum similarity score required for a retrieved node to be considered relevant and included in the final results. Defaults to `0.85`.
Optional
Default: 0.85
The LlamaIndex query mode to use for retrieval. Defaults to `"default"`.
Optional
Default: "default"
Logical condition used to combine `metadata_filters`. Defaults to `"and"`.
Optional
Default: "and"
Optional metadata filters applied before vector results are returned. Defaults to an empty list.
Optional
Default: null
The maximum number of potentially relevant nodes to retrieve from the vector store before applying the similarity threshold. Defaults to `1`.
Optional
Default: 1
Optional
Default: Not specified
Metadata key to filter on.
Required
Default: null
Metadata value used by the filter.
Required
Default: null
Comparison operator applied to the metadata field. Defaults to `FilterOperator.EQ`.
Optional
Default: "=="
Configuration for the HuggingFace embedding model, including model_name, device, trust_remote_code, etc.
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: LLaMAIndexNodeRetriever
class_name: LLaMAIndexNodeRetriever
template_input: InputTemplate
attributes:
embedding_config:
model_name: nomic-ai/nomic-embed-text-v1.5
trust_remote_code: true
device: cpu
embed_batch_size: 8
db_config:
user: my_user
password: my_password
port: 5432
host: localhost
db_name: my_db
table_name: my_embeddings
retrieve_args:
query_mode: default
similarity_top_k: 4
threshold: 0.5Show schema-based configuration skeleton
templates:
- template_name: "LLaMAIndexNodeRetriever"
class_name: "LLaMAIndexNodeRetriever"
attributes:
db_config:
host: "localhost"
port: 5432
user: null
db_name: "sinapsis_db"
password: null
provider: "postgres"
table_name: "sinapsis_table"
retrieve_args:
doc_ids: null
node_ids: null
threshold: 0.85
query_mode: {}
filter_condition: "and"
metadata_filters: null
similarity_top_k: 1
metadata_filters[]:
key: "<required>"
value: "<required>"
operator: {}
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.