Open tituslhy opened 2 weeks ago
The error you're encountering, KeyError: 'sub_dicts'
, indicates that the metadata
attribute in the node
object does not contain the expected sub_dicts
key. This issue arises when using ChromaVectorStore
with VectorMemory
.
To resolve this issue, ensure that the metadata
attribute in the node
object is correctly populated with the sub_dicts
key. You can modify the code where the TextNode
instances are created to include the sub_dicts
key in the metadata
dictionary.
Here's an example of how to modify the TextNode
creation to include the sub_dicts
key:
from llama_index.core.schema import TextNode
nodes = [
TextNode(
text="The Shawshank Redemption",
metadata={
"author": "Stephen King",
"theme": "Friendship",
"year": 1994,
"sub_dicts": [] # Add this line
},
),
TextNode(
text="The Godfather",
metadata={
"director": "Francis Ford Coppola",
"theme": "Mafia",
"year": 1972,
"sub_dicts": [] # Add this line
},
),
# Add similar lines for other TextNode instances
]
The metadata
attribute in the node
object is a dictionary that can contain various key-value pairs. In your case, it seems that the sub_dicts
key is expected but not present. By adding the sub_dicts
key with an appropriate value (e.g., an empty list), you can avoid the KeyError
.
If you need more information on how the metadata
attribute is populated and handled, you can refer to the relevant methods in the ChromaVectorStore
class, such as the add
method, which processes the metadata
attribute before storing it [1].
By ensuring that the metadata
attribute includes the sub_dicts
key, you should be able to resolve the KeyError
and successfully use ChromaVectorStore
with VectorMemory
.
To continue talking to Dosu, mention @dosu.
Bug Description
When attempting to use chromadb as a vector memory, I received a key error on sub_dicts. I'm not sure if this is a chromadb issue because I've no errors when setting the vector_store to None and using the in-memory vector store.
Version
0.10.68
Steps to Reproduce
Assuming you already have a chromaDB instance of messages
Relevant Logs/Tracbacks