Create a RedisConfig object from an existing Redis index.
This class method creates a RedisConfig instance based on the configuration
of an existing index in Redis. It's useful for connecting to and working with
pre-existing Redis vector store indexes.
from_existing_index(
cls,
index_name: str,
redis: Redis
) -> RedisConfigExample:
from redis import Redis
from langchain_redis import RedisConfig
# Assuming an existing Redis connection
redis_client = Redis.from_url("redis://localhost:6379")
config = RedisConfig.from_existing_index(
index_name="my_existing_index",
redis_client=redis_client
)
print(config.index_name) # Output: my_existing_index
print(config.from_existing) # Output: True
Note:
'from_existing' attribute to True, indicating
that the configuration is based on an existing index.