Valkey vector database adapter for cognee
Project description
Cognee Valkey Vector Adapter
A Valkey vector database adapter for Cognee using Valkey Glide, providing high-performance vector storage and retrieval for AI memory applications. Compared to the Redis adapter, Valkey offers a fully open-source, community-driven architecture without the licensing restrictions of Redis. Using Valkey Glide ensures efficient async operations and native support for Valkey’s enhancements, providing optimal compatibility and performance when running on Valkey, making it the best choice for teams adopting Valkey as their primary in-memory vector solution.
Features
- Full support for vector embeddings storage and retrieval
- Batch / pipeline operations for efficient processing
- Automatic embedding generation via configurable embedding engines
- Comprehensive error handling
Installation
If published, the package can be simply installed via pip:
pip install cognee-community-vector-adapter-valkey
In case it is not published yet, you can use poetry to locally build the adapter package:
pip install uv
uv sync --all-extras
Prerequisites
You need a Valkey instance with the Valkey Search module enabled. You can use:
- Valkey:
docker run -d --name valkey -p 6379:6379 valkey/valkey-bundle
Examples
Checkout the examples/ folder!
uv run examples/example.py
You will need an OpenAI API key to run the example script.
Configuration
Configure Valkey as your vector database in cognee:
vector_db_provider: Set to "valkey"vector_db_url: Valkey connection URL (e.g., "valkey://localhost:6379")
Environment Variables
Set the following environment variables or pass them directly in the config:
export VECTOR_DB_URL="valkey://localhost:6379"
Connection URL Examples
# Local Valkey
config.set_vector_db_config({
"vector_db_provider": "valkey",
"vector_db_url": "valkey://localhost:6379"
})
# Valkey with authentication
config.set_vector_db_config({
"vector_db_provider": "valkey",
"vector_db_url": "valkey://user:password@localhost:6379"
})
Requirements
- Python >= 3.11, <= 3.13
- valkey-glide >= 2.1.0
- cognee >= 0.4.0
Advanced Usage
For direct adapter usage (advanced users only):
from cognee.infrastructure.databases.vector.embeddings.EmbeddingEngine import EmbeddingEngine
from cognee_community_vector_adapter_valkey import ValkeyAdapter
from cognee.infrastructure.engine import DataPoint
# Initialize embedding engine and adapter
embedding_engine = EmbeddingEngine(model="your-model")
valkey_adapter = ValkeyAdapter(
url="valkey://localhost:6379",
embedding_engine=embedding_engine
)
# Direct adapter operations
await valkey_adapter.create_collection("my_collection")
data_points = [DataPoint(id="1", text="Hello", metadata={"index_fields": ["text"]})]
await valkey_adapter.create_data_points("my_collection", data_points)
results = await valkey_adapter.search("my_collection", query_text="Hello", limit=10)
Error Handling
The adapter includes comprehensive error handling:
VectorEngineInitializationError: Raised when required parameters are missingCollectionNotFoundError: Raised when attempting operations on non-existent collectionsInvalidValueError: Raised for invalid query parameters- Graceful handling of connection failures and embedding errors
Troubleshooting
Common Issues
- Connection Errors: Ensure Valkey is running and accessible at the specified URL
- Search Module Missing: Make sure Valkey has the Search module enabled
- Embedding Dimension Mismatch: Verify embedding engine dimensions match index configuration
- Collection Not Found: Always create collections before adding data points
Debug Logging
The adapter uses Cognee's logging system. Enable debug logging to see detailed operation logs:
import logging
logging.getLogger("ValkeyAdapter").setLevel(logging.DEBUG)
Development
To contribute or modify the adapter:
- Clone the repository and
cdinto thevalkeyfolder - Install dependencies:
uv sync --all-extras - Make sure a Valkey instance is running (see above)
- Make your changes, test, and submit a PR
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cognee_community_vector_adapter_valkey-0.1.3.tar.gz.
File metadata
- Download URL: cognee_community_vector_adapter_valkey-0.1.3.tar.gz
- Upload date:
- Size: 377.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.11.13 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a186ca3300e9fa4bd524ab4835a7046f6dcaebd4c1c152a18825c62fb4f62b99
|
|
| MD5 |
497990343368ca0a5b933632d0c9a3ae
|
|
| BLAKE2b-256 |
6da52f83c5863f40b38ae33f0500ce912ea5182afe5dcdaf3b9d9b4df70e7d69
|
File details
Details for the file cognee_community_vector_adapter_valkey-0.1.3-py3-none-any.whl.
File metadata
- Download URL: cognee_community_vector_adapter_valkey-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.11.13 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0825807712ad0b5b727133e2f3346fc1481a29955b57db8e337859b7347f9dff
|
|
| MD5 |
4c78d182567d05ade3eb3d94a25c541c
|
|
| BLAKE2b-256 |
30b93a86bff8ceac375537ecc7986fcdd8fc8acc8d54185a0f0184b564b722e9
|