-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat: Make knowledge bases user-stored and support global vars #9458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughUser-scoped knowledge base paths were introduced across API, components, and starter templates. Ingestion and retrieval components were converted to async, added per-user resolution via Langflow API keys/DB, and updated metadata handling with encryption. Tests and templates were updated to reflect async flows, per-user directories, and new inputs. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant API as API (KB v1)
participant Auth as Auth/DB
participant FS as KB Storage (per-user)
Note over API,FS: New per-user KB scoping
U->>API: List/Get/Delete KBs
API->>Auth: Resolve CurrentActiveUser
Auth-->>API: username
API->>FS: Access kb_root/username/[kb_name]
alt Found
FS-->>API: KB entries / OK
API-->>U: 200 (scoped result)
else Not found
API-->>U: 404
end
sequenceDiagram
autonumber
participant UI as Ingestion/ Retrieval Component
participant DB as DB Session
participant Var as Variable Service
participant Enc as Settings (Encrypt/Decrypt)
participant FS as KB Storage (kb_root/username)
Note over UI,FS: Async per-user flow with API key handling
UI->>DB: _get_current_user()
DB-->>UI: username or error
UI->>Var: Resolve embedding API key (optional)
Var-->>UI: api_key or None
UI->>Enc: Encrypt (ingest) / Decrypt (retrieve)
Enc-->>UI: encrypted/decrypted key
UI->>FS: Write/Read KB under kb_root/username
FS-->>UI: Vector store / Documents
UI-->>UI: Build/Query embeddings
UI-->>UI: Return Data/DataFrame
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60–90 minutes Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (3.79%) is below the target coverage (10.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #9458 +/- ##
==========================================
+ Coverage 33.69% 33.96% +0.26%
==========================================
Files 1219 1195 -24
Lines 57613 55823 -1790
Branches 5370 5370
==========================================
- Hits 19411 18958 -453
+ Misses 38132 36795 -1337
Partials 70 70
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
* feat: Make knowledge bases user-stored * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Fix ruff error * [autofix.ci] apply automated fixes * Reuse code * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Don't show options by default * [autofix.ci] apply automated fixes * Pass in the Langflow API key if set * [autofix.ci] apply automated fixes * Update files.py * [autofix.ci] apply automated fixes * Properly handle secret retrieval * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/base/data/kb_utils.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * Update src/backend/base/langflow/base/data/kb_utils.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * Update src/backend/base/langflow/components/data/kb_ingest.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Feedback from review * [autofix.ci] apply automated fixes * Fix other uses of incorrect user * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Feedback from review 2 * [autofix.ci] apply automated fixes * Update kb_ingest.py * [autofix.ci] apply automated fixes * Update tests * [autofix.ci] apply automated fixes * Update kb_ingest.py * [autofix.ci] apply automated fixes * Fix mypy issues * [autofix.ci] apply automated fixes * Update kb_utils.py * Update test_kb_ingest.py * Fix tests * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
* feat: Make knowledge bases user-stored * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Fix ruff error * [autofix.ci] apply automated fixes * Reuse code * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Don't show options by default * [autofix.ci] apply automated fixes * Pass in the Langflow API key if set * [autofix.ci] apply automated fixes * Update files.py * [autofix.ci] apply automated fixes * Properly handle secret retrieval * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/base/data/kb_utils.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * Update src/backend/base/langflow/base/data/kb_utils.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * Update src/backend/base/langflow/components/data/kb_ingest.py Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Feedback from review * [autofix.ci] apply automated fixes * Fix other uses of incorrect user * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Feedback from review 2 * [autofix.ci] apply automated fixes * Update kb_ingest.py * [autofix.ci] apply automated fixes * Update tests * [autofix.ci] apply automated fixes * Update kb_ingest.py * [autofix.ci] apply automated fixes * Fix mypy issues * [autofix.ci] apply automated fixes * Update kb_utils.py * Update test_kb_ingest.py * Fix tests * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
|
Super, this is what I was waiting for. Now, the files I send with session_id will be stored specifically for that session, right? Not in a global pool, but in that session’s own pool? @erichare |



This pull request updates the knowledge base API and related components to support user-specific knowledge bases and authentication using Langflow API keys. The changes ensure that knowledge bases are isolated per user, and access or modification operations require user authentication. The ingestion and retrieval components are refactored to work asynchronously and use the current user's context for all operations.
User Authentication and Knowledge Base Isolation
knowledge_bases.pynow require aCurrentActiveUserparameter and operate on knowledge bases scoped to the authenticated user's directory. [1] [2] [3] [4] [5]Component Refactoring for Async and User Context
kb_ingest.pyandkb_retrieval.pycomponents to use asynchronous methods for knowledge base operations, and to retrieve the current user either from a provided Langflow API key or by creating a new user token if not supplied. [1] [2] [3] [4]API Key Handling and Variable Support
Falsefor security reasons.Dynamic Option Refresh and Error Handling
Internal Codebase Improvements
These changes together ensure that knowledge base data is securely separated by user, and that all access and modification is properly authenticated and tracked.
Summary by CodeRabbit
New Features
Refactor