diff --git a/ee/lib/gitlab/llm/chain/requests/ai_gateway.rb b/ee/lib/gitlab/llm/chain/requests/ai_gateway.rb index 3e09041d73b2de1cf7c21873d97bd70196cf3bdd..7ad35effb180380bf43d0aadb71888d337a8f142 100644 --- a/ee/lib/gitlab/llm/chain/requests/ai_gateway.rb +++ b/ee/lib/gitlab/llm/chain/requests/ai_gateway.rb @@ -169,11 +169,17 @@ def request_body_chat_2(prompt:, options: {}) additional_context: options[:additional_context] }.compact - { + response = { prompt: prompt, options: option_params, model_metadata: options[:model_metadata] - }.compact + } + + if Feature.enabled?(:ai_merge_request_reader_for_chat, user) + response[:unavailable_resources] = %w[Pipelines Vulnerabilities] + end + + response.compact end def payload_params(options) diff --git a/ee/spec/lib/gitlab/llm/chain/requests/ai_gateway_spec.rb b/ee/spec/lib/gitlab/llm/chain/requests/ai_gateway_spec.rb index 780e5e1b580cce757ec96eb7b17fdf26cbf0e575..920fb963305b4de7449bc722f5ad58bf52a10fb4 100644 --- a/ee/spec/lib/gitlab/llm/chain/requests/ai_gateway_spec.rb +++ b/ee/spec/lib/gitlab/llm/chain/requests/ai_gateway_spec.rb @@ -8,6 +8,10 @@ subject(:instance) { described_class.new(user, tracking_context: tracking_context) } + before do + Feature.disable(:ai_merge_request_reader_for_chat) + end + describe 'initializer' do it 'initializes the AI Gateway client' do expect(instance.ai_client.class).to eq(::Gitlab::Llm::AiGateway::Client) @@ -244,6 +248,18 @@ end it_behaves_like 'performing request to the AI Gateway' + + context 'when `ai_merge_request_reader_for_chat` feature flag is enabled' do + before do + stub_feature_flags(ai_merge_request_reader_for_chat: true) + end + + let(:body) do + super().merge(unavailable_resources: %w[Pipelines Vulnerabilities]) + end + + it_behaves_like 'performing request to the AI Gateway' + end end context 'when request is sent to chat tools implemented via agents' do