Find answers from the community

Updated 2 years ago

I thiiiink you can load the index from

I thiiiink you can load the index from storage (as you are doing), call insert_nodes(), and then call persist again to write to disk
index.storage_context.persist(persist_dir=...)
s
L
33 comments
but i thought the storage context contained the index information as well no?
the new storage context is very confusing to be honest 😦
hmm, ngl, it confuses me a bit too lol
what's the exact issue? I'm a little lost with what the problem is lol
so i have a list of documents each is a travel excursion, i want load it into a GPTDocumentSummary and then use the summary to retrieve relevant excursions based on the travel location, right now i load the first document
then when i load the second it doesn't load the summary as well
i see all of the documents in the doc store but when i do the retrieval it only ever returns the first one or "None"
So step one, you built the index using all your travel documents, right?
not all just 1 of the docs
then i iterate through them and add them one by one to the index
Why not build with them all at once, just curious?
because i need to be able to add more over time
as new ones get created
I see I see, that makes sense
I think this might be a symptom of how the summary index works, I need to read the source code a bit more lol
ok so it should work fine with the others but it doesn't. My understanding is that you can define multiple indexes and then save them all together using the storage context
You can, as long as you specify an ID for each index
I still need to try doing that lol
ok i do that though with no problem
i tried switching to vector index and now i'm getting a whole different error, could it be because i'm naming my data chunks?

for i, node in enumerate(nodes, start=1):
node.doc_id = f"{uploaded_filename}chunk{i}of{len(nodes)}"

File "/Users/sheresaidon/virtualenvs/bright-black-ai-chat-template/lib/python3.10/site-packages/llama_index/indices/vector_store/retrievers.py", line 90, in _retrieve
node_ids = [
File "/Users/sheresaidon/virtualenvs/bright-black-ai-chat-template/lib/python3.10/site-packages/llama_index/indices/vector_store/retrievers.py", line 91, in <listcomp>
self._index.index_struct.nodes_dict[idx] for idx in query_result.ids
KeyError: '3ddd2b47-9366-4c78-ba28-36f84f770ec4'
Uhhh that could be why πŸ€” I'm not totally sure tbh
If the nodes were named before constructing the index, i would think that's fine
I really need to play around with these kinds of situations more
i figured it out
man that wasn't easy lol
so first load the storage context, load the index with the storage context, add the nodes to the index with insert(node)
u never have to add it to the storage context
which is super weird and confusing
how does the storage context update lol
That's fun πŸ™ƒ

Calling insert in the index updates the docstore, index struct, and vector store (if applicable) in unison, maybe that's the key πŸ‘€
that would be magic lol
but i don't see how me inserting into an index would update a service_context variable unless i some how associated it no?
Add a reply
Sign up and join the conversation on Discord