import redis from llama_index import ( StorageContext, DocumentSummaryIndex, load_index_from_storage, ServiceContext, ) from llama_index.storage.docstore import RedisDocumentStore from llama_index.storage.index_store import RedisIndexStore from llama_index.vector_stores import RedisVectorStore from llama_index.embeddings import HuggingFaceEmbedding from llama_index.schema import Document REDIS_DB_HOST = "localhost" REDIS_DB_PASSWORD = "" REDIS_DB_PORT = 6380 redis_client = redis.Redis( host=REDIS_DB_HOST, password=REDIS_DB_PASSWORD, port=REDIS_DB_PORT, db=0 ) docstore = RedisDocumentStore.from_redis_client( redis_client=redis_client, namespace="Fail_doc_store", ) index_store = RedisIndexStore.from_redis_client( redis_client=redis_client, namespace="Fail_index_store", ) vector_store = RedisVectorStore( redis_url=f"redis://:{REDIS_DB_PASSWORD}@{REDIS_DB_HOST}:{REDIS_DB_PORT}/0", index_name="Fail_vector_store", index_prefix="llama", overwrite=True, ) storage_context = StorageContext.from_defaults( docstore=docstore, index_store=index_store, vector_store=vector_store ) service_context = ServiceContext.from_defaults( llm=<SOME_LLM_MODEL>, embed_model=HuggingFaceEmbedding( model_name="intfloat/multilingual-e5-large", ), ) document = Document(text="This is a test document", id="test_id") index = DocumentSummaryIndex.from_documents( documents=[document], storage_context=storage_context, service_context=service_context, ) index_id = index.index_id index2 = load_index_from_storage( index_id=index_id, storage_context=storage_context, service_context=service_context ) query_engine = index2.as_query_engine().query("This is a test query")
Traceback (most recent call last): File "/Users/HASHKELL/SHERPAS/Funds/fundssociety-rag/recreable_fail.py", line 56, in <module> query_engine = index2.as_query_engine().query("This is a test query") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/HASHKELL/Library/Caches/pypoetry/virtualenvs/rag-IF6y9IJD-py3.11/lib/python3.11/site-packages/llama_index/core/base_query_engine.py", line 40, in query return self._query(str_or_query_bundle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/HASHKELL/Library/Caches/pypoetry/virtualenvs/rag-IF6y9IJD-py3.11/lib/python3.11/site-packages/llama_index/query_engine/retriever_query_engine.py", line 171, in _query nodes = self.retrieve(query_bundle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/HASHKELL/Library/Caches/pypoetry/virtualenvs/rag-IF6y9IJD-py3.11/lib/python3.11/site-packages/llama_index/query_engine/retriever_query_engine.py", line 127, in retrieve nodes = self._retriever.retrieve(query_bundle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/HASHKELL/Library/Caches/pypoetry/virtualenvs/rag-IF6y9IJD-py3.11/lib/python3.11/site-packages/llama_index/core/base_retriever.py", line 224, in retrieve nodes = self._retrieve(query_bundle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/HASHKELL/Library/Caches/pypoetry/virtualenvs/rag-IF6y9IJD-py3.11/lib/python3.11/site-packages/llama_index/indices/document_summary/retrievers.py", line 176, in _retrieve node_ids = self._index_struct.summary_id_to_node_ids[summary_id]
query()
method of the RedisVectorStore
, it should remove the prefix from the ids. Otherwise, the ids won't line up with anything else.node.id_
to remove the prefix?