Invoke Mutation to Update AI feature Setting
What does this MR do and why?
This MR adds the ability to update an AI Feature Setting from the admin AI feature settings page.
Endpoint: admin/ai/feature_settings
Feature Flag: custom_models_feature_settings_vue_app
Figma: https://www.figma.com/design/xgC4SOG8aFxK2VfSvwjtgW/Self-hosted-models?node-id=828-86426&m=dev
What this MR does:
- Updates the AI Feature Setting using the
aiFeatureSettingUpdate
mutation - When an update is successful, a success toast is shown
- When an update has failed, an error alert is shown
- If the update failed due to an incompatible model choice, this will be shown (won't be needed anymore when models are filtered to only show compatible ones in this work)
- Unspecific errors will produce a generic error message
Out of scope:
- Changes won't be reflected in the UI when the page is refreshed. This is expected as Feature Settings data is stubbed for now. To validate the work, follow instructions below.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Screen_Recording_2024-09-17_at_4.44.42_PM
How to set up and validate locally
Prequisites
You will need an active GitLab ultimate license.
- Start GDK instance in self-managed mode:
GITLAB_SIMULATE_SAAS=0 && gdk start
- In the rails console, enable Code Suggestions and the custom models experiment:
Feature.enable(:ai_custom_model)
ApplicationSetting.first.update(duo_features_enabled: true)
- Enable the admin ai-powered feature settings FF
Feature.enable(:custom_models_feature_settings_vue_app)
Test it!
- Log in as an admin
- Visit the page Admin Area > AI-Powered Features > Self-hosted models
- Create a self-hosted model with
Codegemma
as the model type - Create a self-hosted model with
Mistral
as the model type - Visit Admin Area > AI-Powered Features > Features\
- You should now be able to persist updates made to any AI Feature settings.
Changes won't be reflected when the page is refreshed. This is expected as the query for fetching AI Features and their existing settings is not ready. These Feature Settings are stubbed for now. To validate the updates, open the rails console rails c
Let's target Duo Chat as an example
- To view the feature setting object in the rails console:
::Ai::FeatureSetting.find_by(feature: "duo_chat")
- In the UI, update "Duo Chat" to the
mistral
model created earlier. Reload the feature setting object.ai_self_hosted_model_id
should match the id of the mistral model created (::Ai::SelfHostedModel.find(<ai_self_hosted_model_id>
to cross check it is the correct model) - In the UI, update "Duo Chat" to the
codegemma
model created earlier. This is an incompatible model and should render an error message. TheFeatureSetting
should not update. Ensureai_self_hosted_model_id
on the feature setting has not changed.
Related to #476659 (closed)