diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 39f3b40c5f66bdbf40d4d7ea123d7d4e0b96d28a..f26f5eb9a3760d06a48d10f859997e745df33ffd 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -17751,6 +17751,7 @@ Self-hosted LLM servers. | ---- | ---- | ----------- | | <a id="aiselfhostedmodelcreatedat"></a>`createdAt` | [`Time!`](#time) | Timestamp of creation. | | <a id="aiselfhostedmodelendpoint"></a>`endpoint` | [`String!`](#string) | Endpoint of the self-hosted model server. | +| <a id="aiselfhostedmodelfeaturesettings"></a>`featureSettings` | [`AiFeatureSettingConnection`](#aifeaturesettingconnection) | AI feature settings using the self-hosted model. (see [Connections](#connections)) | | <a id="aiselfhostedmodelhasapitoken"></a>`hasApiToken` | [`Boolean!`](#boolean) | Indicates if an API key is set for the self-hosted model server. | | <a id="aiselfhostedmodelid"></a>`id` | [`AiSelfHostedModelID!`](#aiselfhostedmodelid) | ID of the self-hosted model server. | | <a id="aiselfhostedmodelidentifier"></a>`identifier` | [`String`](#string) | Identifier for 3rd party model provider. | diff --git a/ee/app/graphql/types/ai/self_hosted_models/self_hosted_model_type.rb b/ee/app/graphql/types/ai/self_hosted_models/self_hosted_model_type.rb index bd78264bc7eaf932e9ccde2dc9cb7efbf2f6da76..dcb02a491346dbf9359ac2a116b2bd476b6cd4ef 100644 --- a/ee/app/graphql/types/ai/self_hosted_models/self_hosted_model_type.rb +++ b/ee/app/graphql/types/ai/self_hosted_models/self_hosted_model_type.rb @@ -22,6 +22,11 @@ class SelfHostedModelType < ::Types::BaseObject field :name, String, null: false, description: 'Deployment name of the self-hosted model.' field :updated_at, Types::TimeType, null: true, description: 'Timestamp of last update.' + field :feature_settings, + Types::Ai::FeatureSettings::FeatureSettingType.connection_type, + null: true, + description: 'AI feature settings using the self-hosted model.' + def has_api_token # rubocop:disable Naming/PredicateName -- otherwise resolver matcher don't work object.api_token.present? end diff --git a/ee/app/models/ai/self_hosted_model.rb b/ee/app/models/ai/self_hosted_model.rb index 4047a99f2e5e494b00091b88423fec8394ccb01c..b238dc86ad31084aa32a874cfb5f2c2ccacbc772 100644 --- a/ee/app/models/ai/self_hosted_model.rb +++ b/ee/app/models/ai/self_hosted_model.rb @@ -9,7 +9,7 @@ class SelfHostedModel < ApplicationRecord validates :name, presence: true, uniqueness: true validates :identifier, length: { maximum: 255 }, allow_nil: true - has_many :feature_settings + has_many :feature_settings, foreign_key: :ai_self_hosted_model_id, inverse_of: :self_hosted_model attr_encrypted :api_token, mode: :per_attribute_iv, diff --git a/ee/spec/graphql/types/ai/self_hosted_models/self_hosted_model_type_spec.rb b/ee/spec/graphql/types/ai/self_hosted_models/self_hosted_model_type_spec.rb index d9fc8a5c7b47033ce45f2f736d3e7e088d6fa64c..4b87c692727f8615badd61588f7730d994a7ae21 100644 --- a/ee/spec/graphql/types/ai/self_hosted_models/self_hosted_model_type_spec.rb +++ b/ee/spec/graphql/types/ai/self_hosted_models/self_hosted_model_type_spec.rb @@ -4,7 +4,7 @@ RSpec.describe GitlabSchema.types['AiSelfHostedModel'], feature_category: :"self-hosted_models" do it 'has specific fields' do - expected_fields = %w[id name created_at updated_at model endpoint has_api_token identifier] + expected_fields = %w[id name created_at updated_at model endpoint has_api_token identifier feature_settings] expect(described_class).to include_graphql_fields(*expected_fields) end