Skip to content

Adds column identifier to self-hosted models table

What does this MR do and why?

Adds column 'identifier' to self hosted models. This allow customers to define names for models within servers, such as 'vertex_ai/claude_3_5_sonnet'.

Database

Migration up:

main: == [advisory_lock_connection] object_id: 128880, pg_backend_pid: 8667
main: == 20240923142510 AddModelIdentifierToAiSelfHostedModels: migrating ===========
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- add_column(:ai_self_hosted_models, :model_identifier, :text, {:null=>true, :if_not_exists=>true})
main:    -> 0.0323s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE ai_self_hosted_models\nADD CONSTRAINT check_7e952bb8df\nCHECK ( char_length(model_identifier) <= 255 )\nNOT VALID;\n")
main:    -> 0.0042s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- execute("ALTER TABLE ai_self_hosted_models VALIDATE CONSTRAINT check_7e952bb8df;")
main:    -> 0.0012s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20240923142510 AddModelIdentifierToAiSelfHostedModels: migrated (0.0703s) ==

main: == [advisory_lock_connection] object_id: 128880, pg_backend_pid: 8667
ci: == [advisory_lock_connection] object_id: 129220, pg_backend_pid: 8669
ci: == 20240923142510 AddModelIdentifierToAiSelfHostedModels: migrating ===========
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- add_column(:ai_self_hosted_models, :model_identifier, :text, {:null=>true, :if_not_exists=>true})
ci:    -> 0.0059s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE ai_self_hosted_models\nADD CONSTRAINT check_7e952bb8df\nCHECK ( char_length(model_identifier) <= 255 )\nNOT VALID;\n")
ci:    -> 0.0043s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0003s
ci: -- execute("ALTER TABLE ai_self_hosted_models VALIDATE CONSTRAINT check_7e952bb8df;")
ci:    -> 0.0013s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0003s
ci: == 20240923142510 AddModelIdentifierToAiSelfHostedModels: migrated (0.0282s) ==

ci: == [advisory_lock_connection] object_id: 129220, pg_backend_pid: 8669

Migration down:

main: == [advisory_lock_connection] object_id: 128440, pg_backend_pid: 13499
main: == 20240923142510 AddModelIdentifierToAiSelfHostedModels: reverting ===========
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- remove_column(:ai_self_hosted_models, :model_identifier, {:if_exists=>true})
main:    -> 0.0219s
main: == 20240923142510 AddModelIdentifierToAiSelfHostedModels: reverted (0.0422s) ==

main: == [advisory_lock_connection] object_id: 128440, pg_backend_pid: 13499

How to set up and validate locally

Pre requisits

You will need:

  • An active GitLab ultimate license
  • Run your GDK in self-managed mode GITLAB_SIMULATE_SAAS=0 && gdk start
  • Enable the following flags/configs in the rails console gdk rails c
Feature.enable(:ai_custom_model)
ApplicationSetting.first.update(duo_features_enabled: true)

Test

Navigate to <gdk>/-/graphql-explorer and run the following mutation, which should be succesful:

mutation createSelfHostedModel {
  aiSelfHostedModelCreate(input: {
    name: "test-model-2",
    model: MISTRAL,
    endpoint: "http://localhost:4000",
    identifier: "provider/my-cool-model"
  }) {
    selfHostedModel {
      name
      identifier
    }
  }
}

Related to #485511 (closed)

Edited by Eduardo Bonet

Merge request reports

Loading