diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 1b5f60cb3821571072e179483ad0cafb2685cf0b..c00ea649a1f9bcfdda267f189b0a3a7949380640 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -35937,6 +35937,7 @@ LLMs supported by the self-hosted model features. | Value | Description | | ----- | ----------- | +| <a id="aiacceptedselfhostedmodelsclaude_3"></a>`CLAUDE_3` | Claude 3 model family, suitable for code generation and duo chat. | | <a id="aiacceptedselfhostedmodelscodegemma"></a>`CODEGEMMA` | CodeGemma Code: Suitable for code suggestions. | | <a id="aiacceptedselfhostedmodelscodellama"></a>`CODELLAMA` | Code-Llama Instruct: Suitable for code suggestions. | | <a id="aiacceptedselfhostedmodelscodestral"></a>`CODESTRAL` | Codestral: Suitable for code suggestions. | diff --git a/ee/app/graphql/types/ai/self_hosted_models/accepted_models_enum.rb b/ee/app/graphql/types/ai/self_hosted_models/accepted_models_enum.rb index 074df3ef091451d9d3a3f764057de23ff663b6a4..6c314d963d791ea8e8b72677ff292caa04e4b9d3 100644 --- a/ee/app/graphql/types/ai/self_hosted_models/accepted_models_enum.rb +++ b/ee/app/graphql/types/ai/self_hosted_models/accepted_models_enum.rb @@ -13,6 +13,8 @@ class AcceptedModelsEnum < BaseEnum value 'MISTRAL', 'Mistral: Suitable for code suggestions and duo chat.', value: 'mistral' value 'DEEPSEEKCODER', description: 'Deepseek Coder base or instruct.', value: 'deepseekcoder' value 'LLAMA3', description: 'LLaMA 3: Suitable for code suggestions and duo chat.', value: 'llama3' + value 'CLAUDE_3', description: 'Claude 3 model family, suitable for code generation and duo chat.', + value: 'claude_3' end end end diff --git a/ee/app/helpers/admin/ai/self_hosted_models_helper.rb b/ee/app/helpers/admin/ai/self_hosted_models_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..08610a4f87577105fb94c3f947f040852e020a2f --- /dev/null +++ b/ee/app/helpers/admin/ai/self_hosted_models_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Admin + module Ai + module SelfHostedModelsHelper + def model_choices_as_options + ::Ai::SelfHostedModel + .models + .map { |name, _| { modelValue: name.upcase, modelName: name.capitalize.tr("_", " ") } } + end + end + end +end diff --git a/ee/app/models/ai/self_hosted_model.rb b/ee/app/models/ai/self_hosted_model.rb index b238dc86ad31084aa32a874cfb5f2c2ccacbc772..b2078e2ee25fc126cfadc63574b00fd97e7bc506 100644 --- a/ee/app/models/ai/self_hosted_model.rb +++ b/ee/app/models/ai/self_hosted_model.rb @@ -23,7 +23,8 @@ class SelfHostedModel < ApplicationRecord codegemma: 2, codestral: 3, codellama: 4, - deepseekcoder: 5 + deepseekcoder: 5, + claude_3: 6 } # For now, only OpenAI API format is supported, this method will be potentially diff --git a/ee/app/views/admin/ai/self_hosted_models/edit.html.haml b/ee/app/views/admin/ai/self_hosted_models/edit.html.haml index ca0a791f6963f8ad9e81cf74d5d8cfad24dd2357..de28841927945f04df8008b101083862dd6283ac 100644 --- a/ee/app/views/admin/ai/self_hosted_models/edit.html.haml +++ b/ee/app/views/admin/ai/self_hosted_models/edit.html.haml @@ -1,9 +1,7 @@ - add_to_breadcrumbs s_('AdminSelfHostedModels|Self-hosted models'), admin_labels_path - breadcrumb_title s_('AdminSelfHostedModels|Edit self-hosted model') - if Feature.enabled?(:custom_models_vue_app, current_user) - - model_options = Ai::SelfHostedModel.models.map { |name, _| { modelValue: name.upcase, modelName: name.capitalize } } - - #js-edit-self-hosted-model{ data: { view_model: { model: @self_hosted_model, modelOptions: model_options, basePath: admin_ai_self_hosted_models_path }.to_json(methods: [:api_token]) } } + #js-edit-self-hosted-model{ data: { view_model: { model: @self_hosted_model, modelOptions: model_choices_as_options, basePath: admin_ai_self_hosted_models_path }.to_json(methods: [:api_token]) } } - else - page_title _('Edit'), @self_hosted_model.model, s_('AdminSelfHostedModels|Self-hosted models') %h1.page-title.gl-text-size-h-display diff --git a/ee/app/views/admin/ai/self_hosted_models/new.html.haml b/ee/app/views/admin/ai/self_hosted_models/new.html.haml index 949a5422b0c4088c0fc2857be2ad3f9d8a32c930..a90359873c929aa6712f569fd2b3bd7f550d2f1e 100644 --- a/ee/app/views/admin/ai/self_hosted_models/new.html.haml +++ b/ee/app/views/admin/ai/self_hosted_models/new.html.haml @@ -1,8 +1,6 @@ - page_title s_('AdminSelfHostedModels|Add self-hosted models') - if Feature.enabled?(:custom_models_vue_app, current_user) - - model_options = Ai::SelfHostedModel.models.map { |name, _| { modelValue: name.upcase, modelName: name.capitalize } } - - #js-new-self-hosted-model{ data: { view_model: { basePath: admin_ai_self_hosted_models_path, modelOptions: model_options }.to_json } } + #js-new-self-hosted-model{ data: { view_model: { basePath: admin_ai_self_hosted_models_path, modelOptions: model_choices_as_options }.to_json } } - else %h1.page-title.gl-text-size-h-display = s_('AdminSelfHostedModels|Add self-hosted models') diff --git a/ee/lib/gitlab/ai/feature_settings/feature_metadata.yml b/ee/lib/gitlab/ai/feature_settings/feature_metadata.yml index 1fa8ceda2b377b0faa6af44a3271bb4fd7258fc3..af0acf10bfd3b884c984f8b14999ed2b32387ba0 100644 --- a/ee/lib/gitlab/ai/feature_settings/feature_metadata.yml +++ b/ee/lib/gitlab/ai/feature_settings/feature_metadata.yml @@ -9,6 +9,7 @@ code_generations: - deepseekcoder - mistral - llama3 + - claude_3 code_completions: title: Code Completion release_state: GA @@ -26,3 +27,4 @@ duo_chat: main_feature: Duo Chat compatible_llms: - mistral + - claude_3 diff --git a/ee/spec/graphql/types/ai/self_hosted_models/accepted_models_enum_spec.rb b/ee/spec/graphql/types/ai/self_hosted_models/accepted_models_enum_spec.rb index 9aa5f48e07451ce79258d3fbbd5766332fa7bf66..25189123cdc59e110fa6a8d38c85c9370ba680a0 100644 --- a/ee/spec/graphql/types/ai/self_hosted_models/accepted_models_enum_spec.rb +++ b/ee/spec/graphql/types/ai/self_hosted_models/accepted_models_enum_spec.rb @@ -13,6 +13,7 @@ MISTRAL DEEPSEEKCODER LLAMA3 + CLAUDE_3 ]) end end diff --git a/ee/spec/helpers/admin/ai/self_hosted_models_helper_spec.rb b/ee/spec/helpers/admin/ai/self_hosted_models_helper_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..df5fc482499be1fb26cf18926ed95fcb1992bf76 --- /dev/null +++ b/ee/spec/helpers/admin/ai/self_hosted_models_helper_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe Admin::Ai::SelfHostedModelsHelper, feature_category: :"self-hosted_models" do + describe '#model_choices_as_options' do + it 'returns an array of hashes with model options' do + expected_result = [ + { modelValue: "MISTRAL", modelName: "Mistral" }, + { modelValue: "LLAMA3", modelName: "Llama3" }, + { modelValue: "CODEGEMMA", modelName: "Codegemma" }, + { modelValue: "CODESTRAL", modelName: "Codestral" }, + { modelValue: "CODELLAMA", modelName: "Codellama" }, + { modelValue: "DEEPSEEKCODER", modelName: "Deepseekcoder" }, + { modelValue: "CLAUDE_3", modelName: "Claude 3" } + ] + + expect(helper.model_choices_as_options).to match_array(expected_result) + end + end +end