[Question]: User isolation
Do you need to ask a question?
- [ ] I have searched the existing question and discussions and this question is not already answered.
- [ ] I believe this is a legitimate question, not just a bug or feature request.
Your Question
Currently, it appears that all users are sharing the same database? If we want to allow users to store and access data in their own databases, how should we implement this? Ths~
Additional Context
No response
Have you tried to manage this topic by workspaces?
Using a different workspace per user will just separate the metadata (docs, response cache, chunks, etc.). But changing the workspace does not actually do anything on the database level I believe.
I'm looking for solutions myself as well. Since I'm storing sensitive user data in the graph database, separating the user data is vital.
Proposal
My current thoughts are to pass a custom graph database instance instead of a string of the database;
graph_storage = get_graph_storage_for_user(user_id) # This could be a separate db or a separate schema/table in a db
LightRAG(
working_dir=user_dir,
embedding_func=openai_embed,
graph_storage=graph_storage, # Instead of passing a string (which is currently the limitation)
llm_model_func=gpt_4o_mini_complete,
)
I'll likely open my own issue/question to see why the authors chose to pass a string instead of a graph storage instance directly. I personally think it'd simplify some things, while allowing more extensibility.
Update: I found an existing solution; the namespace_prefix argument. As the docstring states; "Prefix for namespacing stored data across different environments.".
So, this would allow you to put data in separate environments 🙌. Hope it helps
rag_instances[user_id] = LightRAG(
namespace_prefix=user_id,
working_dir=user_dir,
embedding_func=openai_embed,
graph_storage="Neo4JStorage",
llm_model_func=gpt_4o_mini_complete
)
I currently using the docs filtering, so when user query, it only retrieve filtered docs correlated to the user.