redis_client = redis.Redis( host=self.config.get("REDIS_HOST"), port=self.config.get("REDIS_PORT"), password=self.config.get("REDIS_PASSWORD"), ssl=True, ) docstore = RedisDocumentStore.from_redis_client( redis_client=redis_client, namespace=namespace ) storage_context = StorageContext.from_defaults( docstore=self.docstore, index_store=RedisIndexStore.from_redis_client( redis_client=redis_client, namespace=namespace ), )
base_index = load_index_from_storage(storage_context)
try: indices = load_indices_from_storage(self.storage_context) for index in indices: print(index.index_id) base_index = load_index_from_storage(storage_context) print("[INFO] Index found at storage") except ValueError as e: print("[INFO] No index found at storage") base_index = VectorStoreIndex( nodes=[], storage_context=storage_context)
base_retriever = base_index.as_retriever( similarity_top_k=self.similarity_top_k ) retriever = AutoMergingRetriever( base_retriever, self.storage_context, verbose=True ) query_bundle = QueryBundle(query_str=query) retrived_nodes = retriever.retrieve(query_bundle)
RedisVectorStore
first but the primary disadvantage is my redis instance is on upsert and since the legacy initialization requires a redis url and not the redis client that I've been using for docstore and index store:self.redis_client = redis.Redis( host=self.config.get("UPSTASH_REDIS_HOST"), port=self.config.get("UPSTASH_REDIS_PORT"), password=self.config.get("UPSTASH_REDIS_PASSWORD"), ssl=True, )
MODULE not supported
Can't instantiate abstract class BaseNode with abstract methods get_content, get_metadata_str, get_type, hash, set_content (type=type_error)
self.redis_client = redis.Redis( host=self.config.get("UPSTASH_REDIS_HOST"), port=self.config.get("UPSTASH_REDIS_PORT"), password=self.config.get("UPSTASH_REDIS_PASSWORD"), ssl=True, ) self.docstore = RedisDocumentStore.from_redis_client( redis_client=self.redis_client, namespace=self.namespace ) self.vector_store = UpstashVectorStore( url=self.config.get("UPSTASH_VECTOR_URL"), token=self.config.get("UPSTASH_VECTOR_TOKEN"), ) self.storage_context = StorageContext.from_defaults( docstore=self.docstore, index_store=RedisIndexStore.from_redis_client( redis_client=self.redis_client, namespace=self.namespace ), vector_store=self.vector_store )
from llama_index.legacy.vector_stores.redis import RedisVectorStore
pip install llama-index-vector-stores-upstash
from llama_index.vector_stores.uptash import UpstashVectorStore
try: indices = load_indices_from_storage(self.storage_context) for index in indices: print(index.index_id) self.base_index = load_index_from_storage(self.storage_context) print(self.base_index) print("[INFO] Index found at storage") except ValueError as e: print("[INFO] No index found at storage") self.base_index = VectorStoreIndex( nodes=[], storage_context=self.storage_context, )
pip install llama-index-vector-stores-upstash
rediss
url manually seeing my redis client initialization :self.redis_client = redis.Redis( host=self.config.get("UPSTASH_REDIS_HOST"), port=self.config.get("UPSTASH_REDIS_PORT"), password=self.config.get("UPSTASH_REDIS_PASSWORD"), ssl=True, )
upstash
end