The tos_vector backend uses a vector bucket in Volcengine TOS (object storage) as the vector store. Knowledge text is embedded locally by an embedding model, written to a TOS vector index, and retrieved by cosine similarity. On first use, the vector bucket and index are created automatically if they do not exist.
When to use
- You have a Volcengine account and want to host vector data in a TOS vector bucket;
- You need persistent vector storage while keeping control of embedding locally.
Dependencies
Usage
Before running, configure MODEL_EMBEDDING_NAME, MODEL_EMBEDDING_DIM, MODEL_EMBEDDING_API_BASE, and MODEL_EMBEDDING_API_KEY. The extensions extra includes llama-index, embedding adapters, and vector-store connectors. Text is sent to the configured embedding service. For BytePlus or another provider, explicitly set the matching endpoint, model, and credentials; the default Ark endpoint does not automatically switch
Also provide Volcengine AK/SK, account ID, vector-bucket name, and region. Initialization creates or accesses the bucket and index, requires permissions, and may incur charges. Content and vectors are sent to TOS
You can also pass credentials and config explicitly via backend_config:
Parameters
KnowledgeBase parameters
Constructor parameters
backend_config supports the following settings:
TOS vector client config
tos_vector_config is a TOSVectorConfig with env prefix DATABASE_TOS_VECTOR_:
Embedding config
embedding_config is an EmbeddingModelConfig with env prefix MODEL_EMBEDDING_:
Environment variables
add_from_directory and add_from_files are still being refined and may have gaps when handling some files (e.g., documents containing images). Text ingestion (add_from_text) is stable.
Global BytePlus configuration can map AK/SK, but does not automatically switch this backend’s TOS Vector endpoint. Explicitly configure a supported endpoint and region for the target service. Set DATABASE_TOS_VECTOR_SECURITY_TOKEN for a temporary credential token; the outer session_token has no effect. Existing indexes must match the embedding dimension; create a new index and reimport when changing models or dimensions
The example search should return the annual-leave policy. For empty results, check successful ingestion, matching embedding dimensions, completed server processing, network access, and permissions. Managed ingestion may not be immediately searchable. Running the configured Agent also requires model credentials