Skip to content

Add GraphQL Endpoint For Updating Self-hosted Models

What does this MR do and why?

Adds a Graphql mutation for updating a self-hosted model. This query will be invoked by the new Vue app currently in development to replace the existing HAML front-end for self-hosted models. The mutation added here will be leveraged by this piece of work (not yet started)

Note: The Vue UI is currently behind a feature flag custom_models_vue_app

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.

How to set up and validate locally

Prequisites

You will need:

  • An active GitLab ultimate license
  • Disable SAAS mode when running GDK
    • echo $GITLAB_SIMULATE_SAAS should return 0
    • See the docs for more information
  • Run the following commands in your terminal
add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
add_on_purchase = GitlabSubscriptions::AddOnPurchase.create!(add_on: add_on, expires_on: 1.month.from_now, quantity: 5, purchase_xid: 'A-S0001')
Feature.enable(:self_managed_code_suggestions)
Feature.enable(:ai_custom_model)
ApplicationSetting.first.update(duo_features_enabled: true)

Testing the GQL request

  1. Open the graphql explorer: http://gdk.test:3000/-/graphql-explorer
  2. Run the query below, with the test inputs provided
mutation SelfHostedModelUpdate($input: AiSelfHostedModelUpdateInput!) {
  aiSelfHostedModelUpdate(input: $input)  {
    selfHostedModel {
      id
      name
      model
      endpoint
      hasApiToken
    }
  }
}

inputs:

{
  "input": {
    "name": "updated-name",
    "endpoint": "https://updated-endpoint.com",
    "model": "MISTRAL",
    "api_token": "test_api_token"
  }
}

Numbered steps to set up and validate the change are strongly suggested.

Edited by Julie Huang

Merge request reports