LightRAG/logs/2025-01-27-12-30-multitenant-filtering-api-fix.md
Raphaël MANSUY 730c406749 feat: Implement multi-tenant support across graph and query routes
- Enhanced graph_routes.py and query_routes.py to support multi-tenant architecture by introducing tenant-specific RAG instances.
- Updated create_graph_routes and create_query_routes functions to accept rag_manager for tenant management.
- Added get_tenant_rag dependency to all relevant endpoints to ensure tenant context is utilized for operations.
- Modified Vite configuration to include comprehensive API proxy rules for seamless interaction with backend services.
- Implemented cascade delete functionality in tenant_service.py for tenant and knowledge base deletions.
- Added detailed logging and error handling for tenant operations.
- Created audit logs documenting the multi-tenant implementation process and decisions made.
2025-12-05 00:04:29 +08:00

2.1 KiB

Task Log: Multi-Tenant Filtering & API Tab Fix

Date: 2025-01-27 12:30 Mode: beastmode

Todo List Status

  • Step 1: Pipeline/Document routes multi-tenant filtering (completed earlier)
  • Step 2: Graph routes multi-tenant filtering (10 endpoints updated)
  • Step 3: Query/Retrieval routes multi-tenant filtering (3 endpoints updated)
  • Step 4: Update lightrag_server.py to pass rag_manager to all routes
  • Step 5: Fix API tab visibility - Add /static proxy for Swagger UI assets
  • Step 6: Restart Vite dev server to apply proxy configuration change (user action required)

Actions

  • Updated graph_routes.py: Added get_tenant_rag dependency to all 10 graph endpoints
  • Updated query_routes.py: Added get_tenant_rag dependency to 3 query endpoints (/query, /query/stream, /query/data)
  • Updated lightrag_server.py: Pass rag_manager to create_graph_routes() and create_query_routes()
  • Updated vite.config.ts: Added /static proxy to fix Swagger UI asset loading

Decisions

  • Used same multi-tenant pattern across all routes: get_tenant_rag dependency returns tenant-specific LightRAG instance
  • API tab fix: Added /static proxy rather than changing Swagger UI configuration

Next Steps

  • Restart Vite dev server (Ctrl+C and bun run dev) to apply proxy configuration change
  • Test API tab now shows Swagger UI
  • Test graph/retrieval operations filter by KB when switching knowledgebases

Lessons/Insights

  • Swagger UI loads from /docs but assets come from /static/swagger-ui/* - both paths need proxying
  • Vite's base: '/webui/' setting redirects non-proxied paths, causing 404s for Swagger assets
  • Proxy configuration changes require dev server restart to take effect

Files Modified

  1. lightrag/api/routers/graph_routes.py - Multi-tenant support for all graph endpoints
  2. lightrag/api/routers/query_routes.py - Multi-tenant support for all query endpoints
  3. lightrag/api/lightrag_server.py - Pass rag_manager to graph and query route creators
  4. lightrag_webui/vite.config.ts - Added /static proxy for Swagger UI assets