googleapis / googleapis/langchain-google-memorystore-redis-python

RediSearch Not avaialble.

Open
#95 1 comment 0 reactions 1 assignee Claimed by @PingXie View on GitHub
api: redis needs more info priority: p2 type: question
Dominant language
Python
Stars
18
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Hello!

I'm trying to use the GCP Memorystore instance on my Local Mac using port forwarding as mentioned in the [documentation](https://cloud.google.com/memorystore/docs/redis/connect-redis-instance#connecting_from_a_local_machine_with_port_forwarding).

The problem is I want to use it for Vector search and after I connect it using python code I get error for using the `RedisVectorStore`
I tried installing the redis-stack on my local machine and it still doesn't work.

To Solve this problem I tried running Redis Stack locally using Docker, which includes RediSearch:
```sh
docker run -d -p 6379:6379 redis/redis-stack-server
```

#### Environment details

- OS type and version:
- Python version: `3.11.10`
- pip version: `24.2`
- `langchain-google-memorystore-redis` version: `0.2.0`

#### Steps to reproduce

1. Creating the MemoryStore Instance and following the steps to connect to the local using Port Forwarding [documentation](https://cloud.google.com/memorystore/docs/redis/connect-redis-instance#connecting_from_a_local_machine_with_port_forwarding).
2. Download the [vector_store.ipynb](https://github.com/googleapis/langchain-google-memorystore-redis-python/blob/main/docs/vector_store.ipynb)
3. Run the Code shell in order to connect to the Redis Instance and Create the RedisVectorStore with the `index_config`.

#### Code example

```python
import redis
from langchain_google_memorystore_redis import RedisVectorStore
from langchain_google_memorystore_redis import (
DistanceStrategy,
HNSWConfig,
RedisVectorStore,
)

# Connect to a Memorystore for Redis instance
redis_client = redis.from_url("redis://127.0.0.1:6379")
# Configure HNSW index with descriptive parameters
index_config = HNSWConfig(
name="livekit-vectorstore", distance_strategy=DistanceStrategy.COSINE, vector_size=128
)

# Initialize/create the vector store index
RedisVectorStore.init_index(client=redis_client, index_config=index_config)
```

#### Stack trace
```
---------------------------------------------------------------------------
ResponseError Traceback (most recent call last)
Cell In[23], [line 7](vscode-notebook-cell:?execution_count=23&line=7)
[2](vscode-notebook-cell:?execution_count=23&line=2) index_config = HNSWConfig(
[3](vscode-notebook-cell:?execution_count=23&line=3) name="livekit-vectorstore", distance_strategy=DistanceStrategy.COSINE, vector_size=128
[4](vscode-notebook-cell:?execution_count=23&line=4) )
[6](vscode-notebook-cell:?execution_count=23&line=6) # Initialize/create the vector store index
----> [7](vscode-notebook-cell:?execution_count=23&line=7) RedisVectorStore.init_index(client=redis_client, index_config=index_config)

File ~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:342, in RedisVectorStore.init_index(client, index_config)
[333](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:333) command = (
[334](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:334) f"FT.CREATE {index_config.name} ON HASH PREFIX 1 {RedisVectorStore.get_key_prefix(index_config.name)} "
[335](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:335) f"SCHEMA {index_config.field_name} VECTOR {index_config.type} "
(...)
[338](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:338) f"TYPE {index_config.data_type} "
[339](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:339) )
[341](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:341) try:
--> [342](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:342) client.execute_command(command)
[343](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:343) except redis.exceptions.ResponseError as e:
[344](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/langchain_google_memorystore_redis/vectorstore.py:344) if re.match(r"Redis module key \w+ already exists", str(e)):

File ~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/redis/client.py:548, in Redis.execute_command(self, *args, **options)
[545](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/redis/client.py:545) conn = self.connection or pool.get_connection(command_name, **options)
[547](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/redis/client.py:547) try:
--> [548](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/redis/client.py:548) return conn.retry.call_with_retry(
...
--> [536](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/redis/connection.py:536) raise response
[537](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/redis/connection.py:537) finally:
[538](https://file+.vscode-resource.vscode-cdn.net/Users/parshva/SoftmaxAI/Livekit_Redis/~/SoftmaxAI/Livekit_Redis/.conda/lib/python3.11/site-packages/redis/connection.py:538) del response # avoid creating ref cycles

ResponseError: unknown command 'FT.CREATE', with args beginning with: 'livekit-vectorstore' 'ON' 'HASH' 'PREFIX' '1' 'livekit-vectorstore' 'SCHEMA' 'vector' 'VECTOR' 'HNSW' '14' 'TYPE' 'FLOAT32' 'DIM'
```

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.