Replies: 3 comments 5 replies
-
Hey there, @cay89! I'm here to help you out with any bugs, questions, or contributions you may have. Let's tackle this together! To ensure that the Here is an example of how you can modify the @classmethod
def from_vector_store(
cls,
vector_store: BasePydanticVectorStore,
user_id: str, # Add user_id parameter
embed_model: Optional[EmbedType] = None,
# deprecated
service_context: Optional[ServiceContext] = None,
**kwargs: Any,
) -> "VectorStoreIndex":
if not vector_store.stores_text:
raise ValueError(
"Cannot initialize from a vector store that does not store text."
)
kwargs.pop("storage_context", None)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
# Filter nodes by user_id
nodes = [node for node in vector_store.get_all_nodes() if node.user_id == user_id]
return cls(
nodes=nodes,
embed_model=embed_model,
service_context=service_context,
storage_context=storage_context,
**kwargs,
) In this modification, the
|
Beta Was this translation helpful? Give feedback.
-
@dosu It doesn't do what I want either. The If I set the I want it to create records only if they do not exist based on the specified filter. If they do exist, then return the index with the filtered records included. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, this bot is not very helpful for me. I can't believe that this is such a unique use case... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a code snippet that checks based on metadata whether a given file already exists for a particular user in the vector store. If it doesn't exist, it creates the records; if it does exist, it retrieves them.
My problem is that I would like the VectorStoreIndex.from_vector_store(vector_store=vector_store) call to also check if the records belong to the given user, similar to the _is_in_vector_store() method.
How can I achieve this?
Beta Was this translation helpful? Give feedback.
All reactions