cognee-community-vector-adapter-redis 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .idea
12
+ # Env config
13
+ .env
14
+
15
+ # Cognee system
16
+ .cognee-data
17
+ .cognee-system
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: cognee-community-vector-adapter-redis
3
+ Version: 0.0.1
4
+ Summary: Redis vector database adapter for cognee
5
+ Requires-Python: <=3.13,>=3.11
6
+ Requires-Dist: cognee>=0.2.0.dev0
7
+ Requires-Dist: redisvl<=1.0.0,>=0.6.0
8
+ Description-Content-Type: text/markdown
9
+
10
+ <div align="center" dir="auto">
11
+ <img width="250" src="https://raw.githubusercontent.com/redis/redis-vl-python/main/docs/_static/Redis_Logo_Red_RGB.svg" style="max-width: 100%" alt="Redis">
12
+ <h1>🧠 Cognee Redis Vector Adapter</h1>
13
+ </div>
14
+
15
+ <div align="center" style="margin-top: 20px;">
16
+ <span style="display: block; margin-bottom: 10px;">Blazing fast vector similarity search for Cognee using Redis</span>
17
+ <br />
18
+
19
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
20
+ ![Language](https://img.shields.io/badge/python-3.8+-blue.svg)
21
+
22
+ [![Powered by RedisVL](https://img.shields.io/badge/Powered%20by-RedisVL-red.svg)](https://github.com/redis/redis-vl-python)
23
+
24
+ </div>
25
+
26
+ <div align="center">
27
+ <div display="inline-block">
28
+ <a href="https://github.com/topoteretes/cognee"><b>Cognee</b></a>&nbsp;&nbsp;&nbsp;
29
+ <a href="https://docs.redisvl.com"><b>RedisVL Docs</b></a>&nbsp;&nbsp;&nbsp;
30
+ <a href="#examples"><b>Examples</b></a>&nbsp;&nbsp;&nbsp;
31
+ <a href="#troubleshooting"><b>Support</b></a>
32
+ </div>
33
+ <br />
34
+ </div>
35
+
36
+
37
+ ## Features
38
+
39
+ - Full support for vector embeddings storage and retrieval
40
+ - Batch / pipeline operations for efficient processing
41
+ - Automatic embedding generation via configurable embedding engines
42
+ - JSON payload serialization with UUID support
43
+ - Comprehensive error handling
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install cognee-community-vector-adapter-redis
49
+ ```
50
+
51
+ ## Prerequisites
52
+
53
+ You need a Redis instance with the Redis Search module enabled. You can use:
54
+
55
+ 1. **Redis**:
56
+ ```bash
57
+ docker run -d --name redis -p 6379:6379 redis:8.0.2
58
+ ```
59
+
60
+ 2. **Redis Cloud** with the search module enabled: [Redis Cloud](https://redis.io/try-free)
61
+
62
+ ## Examples
63
+ Checkout the `examples/` folder!
64
+
65
+ ```bash
66
+ uv run examples/example.py
67
+ ```
68
+
69
+ >You will need an OpenAI API key to run the example script.
70
+
71
+ ## Usage
72
+
73
+ ```python
74
+ from cognee.infrastructure.databases.vector.embeddings.EmbeddingEngine import EmbeddingEngine
75
+ from cognee_community_vector_adapter_redis import RedisAdapter
76
+
77
+ # Initialize your embedding engine
78
+ embedding_engine = EmbeddingEngine(
79
+ model="your-model",
80
+ # ... other config
81
+ )
82
+
83
+ # Create Redis adapter
84
+ redis_adapter = RedisAdapter(
85
+ url="redis://localhost:6379", # Redis connection URL
86
+ embedding_engine=embedding_engine,
87
+ api_key=None # Optional, not used for Redis but part of interface
88
+ )
89
+
90
+ # Create a collection
91
+ await redis_adapter.create_collection("my_collection")
92
+
93
+ # Add data points
94
+ from cognee.infrastructure.engine import DataPoint
95
+
96
+ data_points = [
97
+ DataPoint(id="1", text="Hello world", metadata={"index_fields": ["text"]}),
98
+ DataPoint(id="2", text="Redis vector search", metadata={"index_fields": ["text"]})
99
+ ]
100
+
101
+ await redis_adapter.create_data_points("my_collection", data_points)
102
+
103
+ # Search for similar vectors
104
+ results = await redis_adapter.search(
105
+ collection_name="my_collection",
106
+ query_text="Hello Redis",
107
+ limit=10
108
+ )
109
+
110
+ # Search with pre-computed vector
111
+ query_vector = await redis_adapter.embed_data(["Hello Redis"])
112
+ results = await redis_adapter.search(
113
+ collection_name="my_collection",
114
+ query_vector=query_vector[0],
115
+ limit=10,
116
+ with_vector=True # Include vectors in results
117
+ )
118
+
119
+ # Batch search
120
+ results = await redis_adapter.batch_search(
121
+ collection_name="my_collection",
122
+ query_texts=["query1", "query2"],
123
+ limit=5
124
+ )
125
+
126
+ # Retrieve specific data points
127
+ retrieved = await redis_adapter.retrieve(
128
+ collection_name="my_collection",
129
+ data_point_ids=["1", "2"]
130
+ )
131
+
132
+ # Delete data points
133
+ await redis_adapter.delete_data_points(
134
+ collection_name="my_collection",
135
+ data_point_ids=["1"]
136
+ )
137
+
138
+ # Check if collection exists
139
+ exists = await redis_adapter.has_collection("my_collection")
140
+ ```
141
+
142
+ ## Configuration
143
+
144
+ The Redis adapter supports the following configuration options:
145
+
146
+ - `url`: Redis connection URL (e.g., "redis://localhost:6379", "redis://user:pass@host:port")
147
+ - `embedding_engine`: The `EmbeddingEngine` to use for text vectorization (required)
148
+ - `api_key`: Optional API key parameter (not used for Redis but part of the interface)
149
+
150
+ ### Connection URL Examples
151
+
152
+ ```python
153
+ # Local Redis
154
+ redis_adapter = RedisAdapter(url="redis://localhost:6379", embedding_engine=engine)
155
+
156
+ # Redis with authentication
157
+ redis_adapter = RedisAdapter(url="redis://user:password@localhost:6379", embedding_engine=engine)
158
+
159
+ # Redis with SSL
160
+ redis_adapter = RedisAdapter(url="rediss://localhost:6380", embedding_engine=engine)
161
+ ```
162
+
163
+
164
+ ## Error Handling
165
+
166
+ The adapter includes comprehensive error handling:
167
+
168
+ - `VectorEngineInitializationError`: Raised when required parameters are missing
169
+ - `CollectionNotFoundError`: Raised when attempting operations on non-existent collections
170
+ - `InvalidValueError`: Raised for invalid query parameters
171
+ - Graceful handling of connection failures and embedding errors
172
+
173
+
174
+ ## Troubleshooting
175
+
176
+ ### Common Issues
177
+
178
+ 1. **Connection Errors**: Ensure Redis is running and accessible at the specified URL
179
+ 2. **Search Module Missing**: Make sure Redis has the Search module enabled
180
+ 3. **Embedding Dimension Mismatch**: Verify embedding engine dimensions match index configuration
181
+ 4. **Collection Not Found**: Always create collections before adding data points
182
+
183
+ ### Debug Logging
184
+
185
+ The adapter uses Cognee's logging system. Enable debug logging to see detailed operation logs:
186
+
187
+ ```python
188
+ import logging
189
+ logging.getLogger("RedisAdapter").setLevel(logging.DEBUG)
190
+ ```
191
+
192
+ ## Development
193
+
194
+ To contribute or modify the adapter:
195
+
196
+ 1. Clone the repository and `cd` into the `redis` folder
197
+ 2. Install dependencies: `uv sync --all-extras`
198
+ 3. Make sure a Redis instance is running (see above)
199
+ 5. Make your changes, test, and submit a PR
@@ -0,0 +1,190 @@
1
+ <div align="center" dir="auto">
2
+ <img width="250" src="https://raw.githubusercontent.com/redis/redis-vl-python/main/docs/_static/Redis_Logo_Red_RGB.svg" style="max-width: 100%" alt="Redis">
3
+ <h1>🧠 Cognee Redis Vector Adapter</h1>
4
+ </div>
5
+
6
+ <div align="center" style="margin-top: 20px;">
7
+ <span style="display: block; margin-bottom: 10px;">Blazing fast vector similarity search for Cognee using Redis</span>
8
+ <br />
9
+
10
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
11
+ ![Language](https://img.shields.io/badge/python-3.8+-blue.svg)
12
+
13
+ [![Powered by RedisVL](https://img.shields.io/badge/Powered%20by-RedisVL-red.svg)](https://github.com/redis/redis-vl-python)
14
+
15
+ </div>
16
+
17
+ <div align="center">
18
+ <div display="inline-block">
19
+ <a href="https://github.com/topoteretes/cognee"><b>Cognee</b></a>&nbsp;&nbsp;&nbsp;
20
+ <a href="https://docs.redisvl.com"><b>RedisVL Docs</b></a>&nbsp;&nbsp;&nbsp;
21
+ <a href="#examples"><b>Examples</b></a>&nbsp;&nbsp;&nbsp;
22
+ <a href="#troubleshooting"><b>Support</b></a>
23
+ </div>
24
+ <br />
25
+ </div>
26
+
27
+
28
+ ## Features
29
+
30
+ - Full support for vector embeddings storage and retrieval
31
+ - Batch / pipeline operations for efficient processing
32
+ - Automatic embedding generation via configurable embedding engines
33
+ - JSON payload serialization with UUID support
34
+ - Comprehensive error handling
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install cognee-community-vector-adapter-redis
40
+ ```
41
+
42
+ ## Prerequisites
43
+
44
+ You need a Redis instance with the Redis Search module enabled. You can use:
45
+
46
+ 1. **Redis**:
47
+ ```bash
48
+ docker run -d --name redis -p 6379:6379 redis:8.0.2
49
+ ```
50
+
51
+ 2. **Redis Cloud** with the search module enabled: [Redis Cloud](https://redis.io/try-free)
52
+
53
+ ## Examples
54
+ Checkout the `examples/` folder!
55
+
56
+ ```bash
57
+ uv run examples/example.py
58
+ ```
59
+
60
+ >You will need an OpenAI API key to run the example script.
61
+
62
+ ## Usage
63
+
64
+ ```python
65
+ from cognee.infrastructure.databases.vector.embeddings.EmbeddingEngine import EmbeddingEngine
66
+ from cognee_community_vector_adapter_redis import RedisAdapter
67
+
68
+ # Initialize your embedding engine
69
+ embedding_engine = EmbeddingEngine(
70
+ model="your-model",
71
+ # ... other config
72
+ )
73
+
74
+ # Create Redis adapter
75
+ redis_adapter = RedisAdapter(
76
+ url="redis://localhost:6379", # Redis connection URL
77
+ embedding_engine=embedding_engine,
78
+ api_key=None # Optional, not used for Redis but part of interface
79
+ )
80
+
81
+ # Create a collection
82
+ await redis_adapter.create_collection("my_collection")
83
+
84
+ # Add data points
85
+ from cognee.infrastructure.engine import DataPoint
86
+
87
+ data_points = [
88
+ DataPoint(id="1", text="Hello world", metadata={"index_fields": ["text"]}),
89
+ DataPoint(id="2", text="Redis vector search", metadata={"index_fields": ["text"]})
90
+ ]
91
+
92
+ await redis_adapter.create_data_points("my_collection", data_points)
93
+
94
+ # Search for similar vectors
95
+ results = await redis_adapter.search(
96
+ collection_name="my_collection",
97
+ query_text="Hello Redis",
98
+ limit=10
99
+ )
100
+
101
+ # Search with pre-computed vector
102
+ query_vector = await redis_adapter.embed_data(["Hello Redis"])
103
+ results = await redis_adapter.search(
104
+ collection_name="my_collection",
105
+ query_vector=query_vector[0],
106
+ limit=10,
107
+ with_vector=True # Include vectors in results
108
+ )
109
+
110
+ # Batch search
111
+ results = await redis_adapter.batch_search(
112
+ collection_name="my_collection",
113
+ query_texts=["query1", "query2"],
114
+ limit=5
115
+ )
116
+
117
+ # Retrieve specific data points
118
+ retrieved = await redis_adapter.retrieve(
119
+ collection_name="my_collection",
120
+ data_point_ids=["1", "2"]
121
+ )
122
+
123
+ # Delete data points
124
+ await redis_adapter.delete_data_points(
125
+ collection_name="my_collection",
126
+ data_point_ids=["1"]
127
+ )
128
+
129
+ # Check if collection exists
130
+ exists = await redis_adapter.has_collection("my_collection")
131
+ ```
132
+
133
+ ## Configuration
134
+
135
+ The Redis adapter supports the following configuration options:
136
+
137
+ - `url`: Redis connection URL (e.g., "redis://localhost:6379", "redis://user:pass@host:port")
138
+ - `embedding_engine`: The `EmbeddingEngine` to use for text vectorization (required)
139
+ - `api_key`: Optional API key parameter (not used for Redis but part of the interface)
140
+
141
+ ### Connection URL Examples
142
+
143
+ ```python
144
+ # Local Redis
145
+ redis_adapter = RedisAdapter(url="redis://localhost:6379", embedding_engine=engine)
146
+
147
+ # Redis with authentication
148
+ redis_adapter = RedisAdapter(url="redis://user:password@localhost:6379", embedding_engine=engine)
149
+
150
+ # Redis with SSL
151
+ redis_adapter = RedisAdapter(url="rediss://localhost:6380", embedding_engine=engine)
152
+ ```
153
+
154
+
155
+ ## Error Handling
156
+
157
+ The adapter includes comprehensive error handling:
158
+
159
+ - `VectorEngineInitializationError`: Raised when required parameters are missing
160
+ - `CollectionNotFoundError`: Raised when attempting operations on non-existent collections
161
+ - `InvalidValueError`: Raised for invalid query parameters
162
+ - Graceful handling of connection failures and embedding errors
163
+
164
+
165
+ ## Troubleshooting
166
+
167
+ ### Common Issues
168
+
169
+ 1. **Connection Errors**: Ensure Redis is running and accessible at the specified URL
170
+ 2. **Search Module Missing**: Make sure Redis has the Search module enabled
171
+ 3. **Embedding Dimension Mismatch**: Verify embedding engine dimensions match index configuration
172
+ 4. **Collection Not Found**: Always create collections before adding data points
173
+
174
+ ### Debug Logging
175
+
176
+ The adapter uses Cognee's logging system. Enable debug logging to see detailed operation logs:
177
+
178
+ ```python
179
+ import logging
180
+ logging.getLogger("RedisAdapter").setLevel(logging.DEBUG)
181
+ ```
182
+
183
+ ## Development
184
+
185
+ To contribute or modify the adapter:
186
+
187
+ 1. Clone the repository and `cd` into the `redis` folder
188
+ 2. Install dependencies: `uv sync --all-extras`
189
+ 3. Make sure a Redis instance is running (see above)
190
+ 5. Make your changes, test, and submit a PR
@@ -0,0 +1,3 @@
1
+ from .redis_adapter import RedisAdapter
2
+
3
+ __all__ = ["RedisAdapter"]