Create Self-Managed model GQL mutation
What does this MR do and why?
The code diff is related to the creation of a new feature in GitLab's GraphQL API, which allows users to create and manage self-hosted AI models. The feature is currently in alpha and experimental, and is only accessible to users with the appropriate permissions.
The changes include the addition of a new mutation called AiSelfHostedModelCreate
, which allows users to create a new self-hosted AI model. The mutation requires several arguments, including the name of the model, the model type, the endpoint of the model server, and an optional API token.
Additionally, the changes include the addition of a new enum called AiAcceptedSelfHostedModels
, which lists the currently supported self-hosted AI models. The enum currently includes two values: MISTRAL
and MIXTRAL
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Prequisites
You need an active
- An active GitLab ultimate license
- Make sure the SAAS mode of your GDK is disable
-
echo $GITLAB_SIMULATE_SAAS
should return0
- 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)
Perform the GQL request
mutation SelfHostedModelCreate($input: AiSelfHostedModelCreateInput!) {
aiSelfHostedModelCreate(input: $input) {
selfHostedModel {
id
name
model
endpoint
hasApiToken
}
}
}
inputs:
{
"input": {
"name": "new-test",
"endpoint": "https://hygraph.com",
"model": "MISTRAL",
"api_token": "test_api_token"
}
}
Related to #461055