Skip to content

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.

  1. Start GDK instance in self-managed mode:

GITLAB_SIMULATE_SAAS=0 && gdk start

  1. In the rails console, enable Code Suggestions and the custom models experiment:
Feature.enable(:ai_custom_model)
ApplicationSetting.first.update(duo_features_enabled: true)
  1. Enable the admin ai-powered feature settings FF
Feature.enable(:custom_models_feature_settings_vue_app)

Test it!

  1. Log in as an admin
  2. Visit the page Admin Area > AI-Powered Features > Self-hosted models
    Screenshot_2024-08-26_at_12.33.35_PM
  3. Create a self-hosted model with Codegemma as the model type
  4. Create a self-hosted model with Mistral as the model type
  5. Visit Admin Area > AI-Powered Features > Features\
  6. 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

  1. To view the feature setting object in the rails console: ::Ai::FeatureSetting.find_by(feature: "duo_chat")
  2. 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)
  3. In the UI, update "Duo Chat" to the codegemma model created earlier. This is an incompatible model and should render an error message. The FeatureSetting should not update. Ensure ai_self_hosted_model_id on the feature setting has not changed.

Related to #476659 (closed)

Edited by Julie Huang

Merge request reports

Loading