Vectrs - Decentralized & Distributed Vector Database 
Overview
Vectrs is a decentralized & distributed vector database designed for efficient storage and retrieval of vector embeddings. It combines P2P networking with advanced vector operations, RAG capabilities, and graph-based relationships, making it ideal for AI-powered distributed applications.
Features
-
Distributed Architecture
- P2P network with load balancing
- Data replication for fault tolerance
- Horizontal scalability
-
Vector Operations
- Multiple similarity metrics (L2, cosine, etc.)
- Different index types (HNSW, Graphine)
- Batch vector operations
- Vector metadata support
-
Graph Capabilities
- Vector relationships management
- Graph-based queries
- Customizable relationship types
-
AI Integration
- RAG (Retrieval-Augmented Generation) workflow
- Custom agent creation and management
- Task analysis capabilities
Installation
pip install vectrs
Usage
Basic Operations
- Initialize and Start a Node
import asyncio
from vectrs.network import KademliaNode
from vectrs.database import VectorDBManager
async def start_node():
# Initialize node
node = KademliaNode(host='127.0.0.1', port=8468)
db_manager = VectorDBManager()
node.set_local_db_manager(db_manager)
# Start node
await node.start()
# Optional: Connect to existing network
await node.bootstrap('bootstrap_host', 8468)
return node
# Run the node
node = asyncio.run(start_node())
- Create Database
from vectrs.database.vectrbase import SimilarityMetric, IndexType
async def create_database(node):
db_manager = VectorDBManager()
# Create database with HNSW index
db_id = db_manager.create_database(
dim=384, # Dimension of your vectors
space=SimilarityMetric.COSINE, # COSINE, L2, or other metrics
max_elements=10000,
index_type=IndexType.HNSW
)
return db_id
db_id = asyncio.run(create_database(node))
- Vector Operations
import numpy as np
async def vector_operations(node, db_id):
# Add single vector
vector = np.random.rand(384).astype(np.float32)
metadata = {"description": "example vector"}
await node.add_vector(db_id, "vector1", vector, metadata)
# Query vector
results = await node.query_vector(db_id, "vector1", k=10)
# Batch add vectors
vectors = {
"vec1": np.random.rand(384).astype(np.float32),
"vec2": np.random.rand(384).astype(np.float32)
}
metadata_list = [{"desc": "vec1"}, {"desc": "vec2"}]
await node.batch_add_vectors(db_id, vectors, metadata_list)
# Update vector
new_vector = np.random.rand(384).astype(np.float32)
await node.update_vector(db_id, "vector1", new_vector, {"updated": True})
# Delete vector
await node.delete_vector(db_id, "vector1")
Graph Operations
async def graph_operations(node, db_id):
# Add relationship between vectors
await node.add_relationship(
db_id,
"vector1",
"vector2",
relationship_type="similar_to"
)
# Get relationships
relationships = await node.get_relationships(db_id, "vector1")
# Graph-based query with depth
results = await node.query_with_graph(
db_id,
"vector1",
k=10,
max_depth=2 # How deep to traverse relationships
)
AI and RAG Features
from vectrs.swarms import Swarms
async def ai_operations(node):
# Initialize Swarms with your Claude API key
api_key = "your-anthropic-api-key" # or use environment variable ANTHROPIC_API_KEY
swarms = Swarms(
node.db_manager,
host='127.0.0.1',
port=8468,
anthropic_api_key=api_key
)
await swarms.initialize()
# Run RAG workflow with a query
result = await swarms.run_rag_workflow(
query="What is the relationship between these vectors?"
)
# Result contains: query, retrieved_context, plan, generated_answer, reflection
# Create and manage AI agent
agent = await swarms.create_custom_agent(
agent_type="reflection", # Available types: reflection, tool, planning
agent_id="agent1"
)
# Check agent status
status = await swarms.get_agent_status("agent1")
# Analyze complex task
analysis = await swarms.analyze_task({
"type": "complex_task",
"data": "Analyze the economic impact of climate change"
})
# Analysis contains: required_skills, complexity, dependencies, estimated_duration
You can provide your Claude API key in three ways:
- Pass it directly to the Swarms constructor
- Set it as an environment variable:
export ANTHROPIC_API_KEY=your-api-key - Use the CLI argument:
python -m vectrs start-node --anthropic_api_key your-api-key
Advanced Features
Graphine Search
async def graphine_search(node, db_id):
# Advanced graph-based similarity search
results = await node.graphine_search(
db_id=db_id,
vector_id="vector1",
k=10, # Number of results
ef=50 # Size of dynamic list for search
)
return results
Command Line Interface
# Start a node
python -m vectrs start-node --host 127.0.0.1 --port 8468
# Create a database
python -m vectrs create-db --dim 384 --space cosine --index_type hnsw
# Add a vector
python -m vectrs add-vector --db_id <db_id> --vector_id "vec1" --vector "0.1,0.2,0.3" --metadata '{"desc":"test"}'
# Query vectors
python -m vectrs query-vector --db_id <db_id> --vector_id "vec1" --query_k 10
# Run RAG workflow
python -m vectrs run-rag --query "What is the relationship between these vectors?"
# Create an AI agent
python -m vectrs create-agent --agent_type reflection --agent_id "agent1"
API Reference
For detailed API documentation, visit our documentation.
Contributing
Contributions are welcome! Please check our contribution guidelines.
License
Apache License 2.0. See LICENSE for details.
Support
- GitHub Issues: Vectrs-beta Issues
- Email: sakib@paralex.tech
- Version: 0.3.3
Metadata
Release files for vectrs 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vectrs-0.3.3.tar.gz | 58.5 kB | Without provenance | Details for vectrs-0.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vectrs-0.3.3-py3-none-any.whl | Python 3 | none | any | Details for vectrs-0.3.3-py3-none-any.whl |
Total release size: 121.2 kB
Release files / vectrs-0.3.3.tar.gz
| Download URL | vectrs-0.3.3.tar.gz |
|---|---|
| Size | 58.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
542c4b46346d987bc551f786baeb9b0e8fbc4420310b6cb675c4a91b540e1d49
|
|
BLAKE2b-256 checksum How to use checksums |
931131e4e400ba222d1cfa40e2298fb555bc111f411ae76628bcb3583b624422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.5
|
Release files / vectrs-0.3.3-py3-none-any.whl
| Download URL | vectrs-0.3.3-py3-none-any.whl |
|---|---|
| Size | 62.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94d5af16d31a5b32d8ae125bf5917b4534afc4f818d0fd9dd83508794a8f1722
|
|
BLAKE2b-256 checksum How to use checksums |
37a89ace9f4ea5b2df9e2ace220116c509cba79d1a2db3a168f1903b85e73cb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.5
|
Security for vectrs 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.