The valori_ffi package provides direct bindings to the Rust kernel. It is designed for high-performance, single-process applications.
The main entry point for the kernel. Usage requires instantiating this class.
from valori_ffi import PyKernel
kernel = PyKernel()Inserts a new vector record into the kernel.
- Arguments:
vector: A list of floats. Must match the kernel's configured dimension (default: 16).
- Returns:
int(The newly assigned Record ID). - Raises:
ValueErrorif dimension mismatch.RuntimeErrorif capacity exceeded.
Performs a deterministic L2 optimized search.
- Arguments:
query: Search vector (list of floats).k: Number of nearest neighbors to return.
- Returns: A list of tuples
(record_id, score).scoreis the raw fixed-point squared distance (lower is closer).
Creates a new node in the knowledge graph.
- Arguments:
kind: Integer representing the node type (User-defined semantic enum).record_id: (Optional) ID of a vector record to associate with this node.
- Returns:
int(The new Node ID).
Creates a directed edge between two nodes.
- Arguments:
from_id: Source Node ID.to_id: Target Node ID.kind: Integer representing the edge relationship type.
- Returns:
int(The new Edge ID).
Serializes the entire kernel state (vectors + graph + index) into a byte array.
- Returns:
bytesobject containing the deterministic state.
Restores the kernel state from a snapshot. This completely overwrites the current state.
- Arguments:
data: Byte array from a previous snapshot.
The valori package provides a pythonic wrapper (Valori) that unifies Local and Remote access.
Factory for creating a client.
from valori import Valori
# Local Mode
client = Valori()
# Remote Mode (Secured)
client = Valori(remote="http://localhost:3000", api_key="secret")- Arguments:
remote: URL ofvalori-node. If None, uses Embedded FFI kernel.api_key: (Optional) Bearer token for authentication in Remote Mode.
Advanced client with text embedding pipeline.
from valori import ProtocolClient
client = ProtocolClient(
embed=my_embed_fn,
remote="http://localhost:3000",
api_key="secret"
)