-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat: make knowledge basis settings accessible by global variables #9981
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
base: main
Are you sure you want to change the base?
Conversation
- Introduced a new migration script to add a 'category' column to the 'variable' table. - Updated the VariableBase model to include a 'category' field with a default value and validation against predefined categories. - Enhanced the VariableCreate and VariableUpdate models to accommodate the new 'category' field. - Added constants for category types and valid categories in the constants module.
- Introduced new module for loading chat models based on user settings. - Implemented caching for initialized chat models to optimize performance. - Added utility functions for saving and loading LLM settings from the database. - Enhanced documentation for new functions to ensure clarity and usability.
- Added a new endpoint to retrieve variables by category, improving organization and access. - Updated the DatabaseVariableService to handle category assignments for variables. - Introduced utility methods for saving and retrieving LLM settings, allowing for better integration with user preferences. - Enhanced validation for category input to ensure compliance with predefined categories.
- Added an asynchronous method to set the LLM based on user ID and session context. - Introduced a new generate method to produce responses from the LLM, handling both string inputs and Message objects. - Enhanced error handling for uninitialized LLM and unsupported input types. - Created a new test file for unit tests related to LLM functionality.
- Introduced a new test file for unit tests related to loading LLM instances. - Implemented tests for various scenarios including missing API keys, caching behavior, and concurrent calls. - Added integration tests to verify model loading with real API keys for OpenAI and Anthropic providers. - Ensured proper handling of settings and parameters during model initialization.
…ariable posting - Introduced a new hook, `useGetVariablesByCategory`, to fetch variables based on the specified category, improving data organization and access. - Updated the `usePostGlobalVariables` function to include an optional `category` parameter, allowing for more flexible variable management. - Enhanced error handling and type definitions for better integration with Axios and React Query.
- Introduced a new LLMSettingsPage component for configuring Large Language Model settings. - Updated the settings navigation to include a link to the new LLM settings page. - Enhanced the settings page with form handling for provider, model, base URL, and API key, utilizing React Hook Form for state management. - Implemented asynchronous saving of settings with error handling and user feedback through alerts.
- Added validation to ensure that required fields (provider, model, api_key) are present in the LLM settings. - Introduced a clear error message for users when any of the required fields are missing, improving user experience and robustness of the service.
- Introduced `get_global_llm` method to fetch the global LLM instance asynchronously. - Enhanced the component's ability to manage LLM initialization and retrieval, improving overall performance and usability.
…ition - Corrected the down_revision identifier in the migration script to ensure proper migration order. - Maintained consistency with the latest migration changes, enhancing the robustness of the migration process.
Eliminated the `_llm` attribute from the `Component` class to streamline the code and improve clarity. This change enhances maintainability by removing unnecessary components.
Introduced an abstract method `get_by_category` in the `VariableService` class to allow asynchronous retrieval of variables for a user based on a specified category. This addition enhances the service's functionality and supports better organization of variable management.
Added a new category, CATEGORY_KB, to the VALID_CATEGORIES list in constants.py to enhance the categorization of variables. This change improves the flexibility and organization of variable management within the service.
Updated the Alembic migration script to add a new 'category' column to the 'variable' table, ensuring it is non-nullable with a default value of 'global'. The migration also handles existing nullable 'category' columns by updating NULL values before altering the column to be non-nullable. This change enhances data integrity and categorization within the variable management system.
…ependencies Removed several deprecated and unused dependencies from package-lock.json to streamline the project and improve maintainability. This cleanup enhances the overall health of the dependency tree and reduces potential security vulnerabilities.
…configuration Refactored the settings page by removing the LLMSettingsPage and introducing the KBSettingsPage. Updated routing and UI elements to reflect the new Knowledge Base settings, enhancing the configuration options for users. This change improves the organization of settings related to Knowledge Bases and streamlines the user experience.
Added a new module for a database-driven vector store factory that allows the creation of vector store instances based on user-specific configurations. This includes the implementation of a protocol for vector stores, an adapter for the LangChain Chroma vector store, and a mock OpenSearch vector store for testing purposes. The factory function `build_kb_vector_store` retrieves user configurations and builds the appropriate vector store instance, enhancing the flexibility and robustness of the knowledge base management system.
Introduced a new module containing abstract and concrete classes for metadata adapters that facilitate provider-agnostic metadata extraction from various vector store backends, including Chroma and OpenSearch. This enhancement provides a unified interface for metadata operations, improving the flexibility and robustness of knowledge base management. The implementation includes methods for retrieving documents, metadata, and embeddings, as well as provider-specific information.
… configuration Refactored the `get_kb_metadata` function to be asynchronous and user-aware, allowing for enhanced metadata extraction from knowledge base directories. Integrated a new vector store creation process that utilizes user-specific configurations, improving the robustness and flexibility of metadata operations. This change also includes better error handling and a structured return of minimal metadata in case of failures.
Updated the KnowledgeIngestionComponent and KnowledgeRetrievalComponent to utilize a new database-driven vector store factory, enhancing user context handling during vector store creation and retrieval. This change improves error handling by ensuring user IDs are validated before operations, and replaces direct Chroma instantiation with a more flexible factory approach. The refactor aims to streamline vector store interactions and improve the robustness of knowledge base management.
Introduced new unit tests for knowledge bases, including tests for database-driven vector store factory, enhanced metadata adapters, and KB variable service integration. These tests improve coverage and ensure robust functionality across various components, enhancing the reliability of knowledge base management. The additions include tests for creating and retrieving metadata, handling different vector store providers, and validating KB variable structures.
Introduced new unit tests for knowledge bases, including tests for database-driven vector store factory, enhanced metadata adapters, and KB variable service integration. These tests improve coverage and ensure robust functionality across various components, enhancing the reliability of knowledge base management. The additions include tests for creating and retrieving metadata, handling different vector store providers, and validating KB variable structures.
…d configuration types - Introduced `OpenSearchVectorStoreAdapter` to implement the `VectorStoreProtocol`, enabling seamless interaction with OpenSearch. - Added `BaseKBConfig`, `ChromaKBConfig`, and `OpenSearchKBConfig` TypedDicts for structured configuration management. - Updated `build_kb_vector_store` to return the new OpenSearch adapter and handle configuration more robustly. - Removed the mock OpenSearch vector store, replacing it with a real implementation for improved functionality and testing. - Enhanced error handling and documentation throughout the OpenSearch integration for better clarity and usability.
…ling - Enhanced the `OpenSearchMetadataAdapter` to support both `get` and `search` methods for retrieving documents and metadata, improving flexibility. - Updated error logging to use a consistent format for better clarity. - Refactored `get_document_count` to handle different methods of counting documents, ensuring robustness. - Adjusted docstrings for clarity and accuracy regarding embeddings retrieval support.
- Refactored the authentication configuration methods in the `OpenSearchVectorStoreComponent` to support both class-level and instance-level authentication setups. - Improved the `_build_auth_kwargs` method to accept parameters directly, allowing for more flexible authentication configurations. - Added a new instance method `_build_auth_kwargs_instance` to utilize instance attributes for authentication. - Updated the `build_client` and `build_client_instance` methods to streamline client creation with enhanced authentication handling. - Enhanced docstrings for clarity and completeness regarding authentication modes and parameters.
- Added a blank line in `test_llm_load.py` to enhance code readability and maintain consistent formatting throughout the test suite.
- Replaced instances of `MockOpenSearchVectorStore` with `OpenSearchVectorStoreAdapter` in unit tests for improved accuracy and consistency. - Enhanced test cases to create mock OpenSearch clients and ensure proper functionality of the adapter. - Updated assertions to reflect changes in the adapter's behavior, ensuring robust testing of metadata extraction and adapter creation.
|
✅ Component index has been automatically updated due to changes in New Index: |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #9981 +/- ##
==========================================
- Coverage 30.16% 30.00% -0.17%
==========================================
Files 1313 1315 +2
Lines 59259 59535 +276
Branches 8876 8909 +33
==========================================
- Hits 17877 17865 -12
- Misses 40565 40852 +287
- Partials 817 818 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|



This pull request introduces major improvements to the Knowledge Base (KB) and Variable management systems, focusing on making KB vector store selection user-configurable via the database, enhancing metadata extraction, and extending the Variable API with category support. The changes increase flexibility for multi-user and multi-provider environments and improve API robustness.
Knowledge Base Vector Store and Metadata System Overhaul:
vector_store_factorymodule that builds KB vector store instances (e.g., Chroma, OpenSearch) based on per-user configuration stored in the database, using a protocol and adapter pattern for extensibility. This enables dynamic, user-specific backend selection.get_kb_metadatafunction is now async and receivesuser_idto support this. [1] [2] [3] [4] [5]Variable API and Database Enhancements:
categorycolumn to thevariabletable, defaulting to"global". This supports categorizing variables (e.g., for KB configuration).categoryfield.Dependency and Import Updates:
Chromafrom files that now rely on the new vector store factory, ensuring all vector store interactions go through the new abstraction layer. [1] [2]These changes lay the groundwork for supporting multiple KB backends per user and provide a more robust, extensible foundation for knowledge base and variable management.
Summary by CodeRabbit
New Features
Improvements
Database
Tests