Add embedding model in details in search page
What does this MR do and why?
For Self-managed instances with Self-hosted AIGW, we want to allow users to select the embedding model through the Admin UI.
Given the amount of changes needed to support this, the change is split into several MRs:
- !232069 (merged) & !232569 (merged) - Add validations through the json schema and the
EmbeddingModelActivationService - !230649 (merged) introduces the Semantic Search embeddings configuration page, accessible through the url:
<gitlab-url>/admin/application_settings/semantic_search_embeddings/<collection_key>. - This MR adds a link to the Semantic Search embeddings configuration page in the main Admin -> Search page -> Semantic Search section
Changes summary
-
Updated: Availability of the Semantic Search section in the Admin -> Search page
- Before: Checks for license and feature availability are called directly in the view file
- After: Checks for availability is done in a controller and the result is assigned to a
@semantic_search_availablevariable:- this makes use of the
ActiveContext.semantic_search_available?method introduced in Semantic Search: Add Embedding Model admin page (!230649 - merged) - this further checks if instance uses the GitLab-selected model OR if instance allows model selection by user
- this makes use of the
-
New: Under the Semantic Search section, we list the embedding models per collection (for now only the Code collection)
- Scenarios:
- if the connection is not yet configured, an information message is displayed
- if the collection record is not yet created, an information message is displayed (this scenarios happens just after a connection is configured, but before the migration for creating collections has run)
- if the collection record is present, the model details are shown
- if instance does not allow model selection by user, the "change model" button is not shown
- if instance allows model selection by user, the "change model" button is shown
- if instance allows model selection by user but there is a next model, the "change model" button is shown but disabled
- Scenarios:
References
- Main Issue: [ActiveContext Code] Select embedding model in UI (#582638 - closed)
- Rollout Issue: [FF] `semantic_search_user_model_selection` -- (#597029)
Screenshots or screen recordings
Scenario: Semantic Search is unavailable
Scenarios: embedding model configuration is unavailable
Connection is not yet configured
Collection record not present
Scenarios: when user can select the model
No models configured
Current model configured
Switching to next model
Scenarios: when GitLab selects the model
Current model configured
Switching to next model
How to set up and validate locally
Scenario: semantic search unavailable
-
Do one of the following setups:
- make
License.ai_features_available?return false - make
::Gitlab::CurrentSettings.duo_features_enabled?return false - simulate an SM instance with a Self-hosted AIGW, and ensure FF is disabled
- set environment variable:
GITLAB_SIMULATE_SAAS=0 - on the rails console, run:
::Ai::Setting.instance.update!(ai_gateway_url: 'http://gdk.test:3000') - on the rails console, run:
Feature.disable(:semantic_search_user_model_selection)
- set environment variable:
- make
-
Verify that the Admin -> Search page does not have a Semantic Search section
Scenarios: semantic search is available
Setup:
- ensure
License.ai_features_available?returns true - ensure
::Gitlab::CurrentSettings.duo_features_enabled?returns true - further instance setups:
- instance where GitLab selects the model, do any one of the following:
- set environment variable:
GITLAB_SIMULATE_SAAS=1 - on the rails console, run:
::Ai::Setting.instance.update!(ai_gateway_url: nil)
- set environment variable:
- instance where user can select the model
- set environment variable:
GITLAB_SIMULATE_SAAS=0 - on the rails console, run:
::Ai::Setting.instance.update!(ai_gateway_url: 'http://gdk.test:3000') - on the rails console, run:
Feature.enable(:semantic_search_user_model_selection)
- set environment variable:
- instance where GitLab selects the model, do any one of the following:
Connection is not yet configured
- If there is an active connection, deactivate it:
Ai::ActiveContext::Connection.active&.deactivate! - Verify that a message is displayed: "Embedding model configuration is unavailable - Collection record not present"
Collection record has not been created yet
- Ensure you have an active connection
- Ensure that
::Ai::ActiveContext::Collections::Code.collection_recordisnil. - Verify that a message is displayed: "Embedding model configuration is unavailable - Connection not configured"
Collection record embedding model details are set
-
Setup: define a test GitLab-managed model for checking different model details
diff --git a/ee/app/models/ai/active_context/embedding.rb b/ee/app/models/ai/active_context/embedding.rb index ceec99824a8e..e18eb9fbd46a 100644 --- a/ee/app/models/ai/active_context/embedding.rb +++ b/ee/app/models/ai/active_context/embedding.rb @@ -29,6 +29,9 @@ module Embedding 'text_embedding_005_vertex' => { model_name: 'text-embedding-005 - Vertex', batch_size: TEXT_EMBEDDING_VERTEX_BATCH_SIZE + }, + 'embedding_001_test' => { + model_name: 'embedding-001 - TEST' } }.freeze -
Update the
current_indexing_embedding_modeland verify that the current model details are displayed correctly::Ai::ActiveContext::Collections::Code.collection_record.update_metadata!( current_indexing_embedding_model: { model_type: 'gitlab_managed', model_ref: 'text_embedding_005_vertex', field: "embeddings_v1", dimensions: 768 } ) -
Update the
next_indexing_embedding_modeland verify that the next model details are displayed correctly::Ai::ActiveContext::Collections::Code.collection_record.update_metadata!( next_indexing_embedding_model: { model_type: 'gitlab_managed', model_ref: 'embedding_001_test', field: "embeddings_v2", dimensions: 768 } ) -
"Set model" / "Change model" button:
- if you are in an instance where GitLab selects the model, verify that this button is not shown
- if you are in an instance where user can select the model, verify that this button is shown
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #582638 (closed)







