Cognee Community Weaviate Vector Adapter
This is a community-maintained adapter that enables Cognee to work with Weaviate as a vector database.
Installation
If published, the package can be simply installed via pip:
pip install cognee-community-vector-adapter-weaviate
In case it is not published yet, you can use poetry to locally build the adapter package:
pip install poetry
poetry install # run this command in the directory containing the pyproject.toml file
Connection Setup
The provided code creates an async client connected to a remote instance of Weaviate. If you want to connect to a local
instance, like running a docker container locally and connecting to it, you need to change a few lines of code.
In the weaviate_adapter.py file inside the .../weaviate/cognee_community_vector_adapter_weaviate directory, replace
the following lines in the constructor:
self.client = weaviate.use_async_with_weaviate_cloud(
cluster_url=url,
auth_credentials=weaviate.auth.AuthApiKey(api_key),
additional_config=wvc.init.AdditionalConfig(timeout=wvc.init.Timeout(init=30)),
)
with the following:
self.client = weaviate.use_async_with_local(
host="localhost",
port=8080,
grpc_port=50051
)
You can use the docker command provided by Weaviate (https://docs.weaviate.io/deploy/installation-guides/docker-installation) to run Weaviate with default settings. The command looks something like this, specifying the ports for connection:
docker run -p 8080:8080 -p 50051:50051 cr.weaviate.io/semitechnologies/weaviate:1.32.4
Usage
import asyncio
import os
from cognee import config, prune, add, cognify, search, SearchType
# Import the register module to enable Weaviate support
import cognee_community_vector_adapter_weaviate.register
async def main():
# Configure databases
config.set_relational_db_config(
{
"db_provider": "sqlite",
}
)
config.set_vector_db_config(
{
"vector_db_provider": "weaviate",
"vector_db_url": os.getenv("VECTOR_DB_URL"), # or your Weaviate URL
"vector_db_key": os.getenv("VECTOR_DB_KEY"), # or your API key
}
)
config.set_graph_db_config(
{
"graph_database_provider": "networkx",
}
)
# Optional: Clean previous data
await prune.prune_data()
await prune.prune_system()
# Add and process your content
text = "Your text content here"
await add(text)
await cognify()
# Search
search_results = await search(
query_type=SearchType.GRAPH_COMPLETION, query_text="Your search query"
)
for result in search_results:
print(result)
if __name__ == "__main__":
asyncio.run(main())
Configuration
The Weaviate adapter requires the following configuration parameters:
vector_db_url: Your Weaviate cluster endpoint URLvector_db_key: Your Weaviate API keyvector_db_provider: Set to "weaviate"
Environment Variables
Set the following environment variables or pass them directly in the config:
export VECTOR_DB_URL="https://your-weaviate-instance.weaviate.network"
export VECTOR_DB_KEY="your-api-key"
Alternative: You can also use the .env.template file from the main cognee repository. Copy it to your project directory, rename it to .env, and fill in your Weaviate configuration values.
Requirements
- Python >= 3.11, <= 3.13
- weaviate-client >= 4.9.6, < 5.0.0
- cognee == 1.4.2
Features
- Full vector search capabilities
- Batch operations support
- Async/await support
- Retry logic for better reliability
- Collection management
- Data point indexing and retrieval
Metadata
Release files for cognee-community-vector-adapter-weaviate 0.2.0
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 | |
|---|---|---|---|---|
| cognee_community_vector_adapter_weaviate-0.2.0.tar.gz | 302.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cognee_community_vector_adapter_weaviate-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 310.7 kB
Release files / cognee_community_vector_adapter_weaviate-0.2.0.tar.gz
| Download URL | cognee_community_vector_adapter_weaviate-0.2.0.tar.gz |
|---|---|
| Size | 302.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d93627d6316ce46abccd4eaedb0fa8de6f57dcb70b1d04f4d9efa39d1cfbfce
|
|
BLAKE2b-256 checksum How to use checksums |
86426a9035fe3a03e79f8f002b6c43aa9682d8ed85733767f83d6c82ec3230e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0
|
Release files / cognee_community_vector_adapter_weaviate-0.2.0-py3-none-any.whl
| Download URL | cognee_community_vector_adapter_weaviate-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a0105a3b90666852b1feb771fba721b369b8d78a84e949e15f3808e354d6698
|
|
BLAKE2b-256 checksum How to use checksums |
3a6ae78d8bcff9a243f3b1a0a06d7b49a14142fea3d9f8ff37ee9980cf0854a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0
|
Security for cognee-community-vector-adapter-weaviate 0.2.0
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.