From fc9628d7e102f3645526efbec0ff5da9e38f5217 Mon Sep 17 00:00:00 2001 From: Jessie Young <jessieyoung@gitlab.com> Date: Wed, 15 Nov 2023 00:57:05 +0000 Subject: [PATCH] Remove unused "TanukiBot" code * Before the name "GitLab Duo" existed, we called Duo Chat "Tanuki Bot". As a result, there is a lot of code in gitlab-org/gitlab that references this old name. * The code here was using the old name and is no longer used * https://gitlab.com/gitlab-org/gitlab/-/issues/431311 * https://gitlab.com/gitlab-org/gitlab/-/issues/431310 --- .rubocop_todo/rspec/named_subject.yml | 1 - doc/api/graphql/reference/index.md | 10 ---- .../graphql/types/ai/tanuki_bot_input_type.rb | 14 ----- ee/app/services/llm/execute_method_service.rb | 1 - ee/app/services/llm/tanuki_bot_service.rb | 23 -------- .../llm/anthropic/completions/tanuki_bot.rb | 29 --------- ee/lib/gitlab/llm/completions_factory.rb | 5 -- .../anthropic/completions/tanuki_bot_spec.rb | 59 ------------------- .../services/llm/tanuki_bot_service_spec.rb | 51 ---------------- rubocop/rubocop-code_reuse.yml | 1 - 10 files changed, 194 deletions(-) delete mode 100644 ee/app/graphql/types/ai/tanuki_bot_input_type.rb delete mode 100644 ee/app/services/llm/tanuki_bot_service.rb delete mode 100644 ee/lib/gitlab/llm/anthropic/completions/tanuki_bot.rb delete mode 100644 ee/spec/lib/gitlab/llm/anthropic/completions/tanuki_bot_spec.rb delete mode 100644 ee/spec/services/llm/tanuki_bot_service_spec.rb diff --git a/.rubocop_todo/rspec/named_subject.yml b/.rubocop_todo/rspec/named_subject.yml index 45c9cf90b0327..c99d6784b735f 100644 --- a/.rubocop_todo/rspec/named_subject.yml +++ b/.rubocop_todo/rspec/named_subject.yml @@ -1097,7 +1097,6 @@ RSpec/NamedSubject: - 'ee/spec/services/llm/generate_test_file_service_spec.rb' - 'ee/spec/services/llm/git_command_service_spec.rb' - 'ee/spec/services/llm/resolve_vulnerability_service_spec.rb' - - 'ee/spec/services/llm/tanuki_bot_service_spec.rb' - 'ee/spec/services/member_roles/create_service_spec.rb' - 'ee/spec/services/merge_request_approval_settings/update_service_spec.rb' - 'ee/spec/services/merge_requests/merge_service_spec.rb' diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index ebd053bdb5a23..5649b65c598fa 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -1264,7 +1264,6 @@ Input type: `AiActionInput` | <a id="mutationaiactionresolvevulnerability"></a>`resolveVulnerability` | [`AiResolveVulnerabilityInput`](#airesolvevulnerabilityinput) | Input for resolve_vulnerability AI action. | | <a id="mutationaiactionsummarizecomments"></a>`summarizeComments` | [`AiSummarizeCommentsInput`](#aisummarizecommentsinput) | Input for summarize_comments AI action. | | <a id="mutationaiactionsummarizereview"></a>`summarizeReview` | [`AiSummarizeReviewInput`](#aisummarizereviewinput) | Input for summarize_review AI action. | -| <a id="mutationaiactiontanukibot"></a>`tanukiBot` | [`AiTanukiBotInput`](#aitanukibotinput) | Input for tanuki_bot AI action. | #### Fields @@ -32438,15 +32437,6 @@ see the associated mutation type above. | ---- | ---- | ----------- | | <a id="aisummarizereviewinputresourceid"></a>`resourceId` | [`AiModelID!`](#aimodelid) | Global ID of the resource to mutate. | -### `AiTanukiBotInput` - -#### Arguments - -| Name | Type | Description | -| ---- | ---- | ----------- | -| <a id="aitanukibotinputquestion"></a>`question` | [`String!`](#string) | GitLab documentation question for AI to answer. | -| <a id="aitanukibotinputresourceid"></a>`resourceId` | [`AiModelID!`](#aimodelid) | Global ID of the resource to mutate. | - ### `AlertManagementPayloadAlertFieldInput` Field that are available while modifying the custom mapping attributes for an HTTP integration. diff --git a/ee/app/graphql/types/ai/tanuki_bot_input_type.rb b/ee/app/graphql/types/ai/tanuki_bot_input_type.rb deleted file mode 100644 index 4b477dd1f5426..0000000000000 --- a/ee/app/graphql/types/ai/tanuki_bot_input_type.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module Types - module Ai - class TanukiBotInputType < BaseMethodInputType - graphql_name 'AiTanukiBotInput' - - argument :question, GraphQL::Types::String, - required: true, - validates: { allow_blank: false }, - description: 'GitLab documentation question for AI to answer.' - end - end -end diff --git a/ee/app/services/llm/execute_method_service.rb b/ee/app/services/llm/execute_method_service.rb index 8656a9140742b..47c0ca6b00b32 100644 --- a/ee/app/services/llm/execute_method_service.rb +++ b/ee/app/services/llm/execute_method_service.rb @@ -11,7 +11,6 @@ class ExecuteMethodService < BaseService summarize_comments: Llm::GenerateSummaryService, summarize_review: Llm::MergeRequests::SummarizeReviewService, explain_code: Llm::ExplainCodeService, - tanuki_bot: Llm::TanukiBotService, generate_test_file: Llm::GenerateTestFileService, generate_description: Llm::GenerateDescriptionService, generate_commit_message: Llm::GenerateCommitMessageService, diff --git a/ee/app/services/llm/tanuki_bot_service.rb b/ee/app/services/llm/tanuki_bot_service.rb deleted file mode 100644 index 8b09467406803..0000000000000 --- a/ee/app/services/llm/tanuki_bot_service.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -module Llm - class TanukiBotService < BaseService - def valid? - super && Gitlab::Llm::TanukiBot.enabled_for?(user: user) - end - - private - - def ai_action - :tanuki_bot - end - - def perform - schedule_completion_worker - end - - def content(_action_name) - options[:question] - end - end -end diff --git a/ee/lib/gitlab/llm/anthropic/completions/tanuki_bot.rb b/ee/lib/gitlab/llm/anthropic/completions/tanuki_bot.rb deleted file mode 100644 index dc966236e9711..0000000000000 --- a/ee/lib/gitlab/llm/anthropic/completions/tanuki_bot.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Llm - module Anthropic - module Completions - class TanukiBot < Gitlab::Llm::Completions::Base - # After we remove REST API, refactor so that we use methods defined in templates/tanuki_bot.rb, e.g.: - # initial_prompt = ai_prompt_class.initial_prompt(question) - def execute - question = options[:question] - - response_modifier = ::Gitlab::Llm::TanukiBot.new( - current_user: user, - question: question, - tracking_context: tracking_context - ).execute - - ::Gitlab::Llm::GraphqlSubscriptionResponseService.new( - user, resource, response_modifier, options: response_options - ).execute - - response_modifier - end - end - end - end - end -end diff --git a/ee/lib/gitlab/llm/completions_factory.rb b/ee/lib/gitlab/llm/completions_factory.rb index afb9b368f75ef..07154b7620a5c 100644 --- a/ee/lib/gitlab/llm/completions_factory.rb +++ b/ee/lib/gitlab/llm/completions_factory.rb @@ -29,11 +29,6 @@ class CompletionsFactory prompt_class: ::Gitlab::Llm::VertexAi::Templates::ExplainCode, feature_category: :ai_abstraction_layer }, - tanuki_bot: { - service_class: ::Gitlab::Llm::Anthropic::Completions::TanukiBot, - prompt_class: ::Gitlab::Llm::Anthropic::Templates::TanukiBot, - feature_category: :ai_abstraction_layer - }, generate_test_file: { service_class: ::Gitlab::Llm::VertexAi::Completions::GenerateTestFile, prompt_class: ::Gitlab::Llm::Templates::GenerateTestFile, diff --git a/ee/spec/lib/gitlab/llm/anthropic/completions/tanuki_bot_spec.rb b/ee/spec/lib/gitlab/llm/anthropic/completions/tanuki_bot_spec.rb deleted file mode 100644 index b8654ab28c612..0000000000000 --- a/ee/spec/lib/gitlab/llm/anthropic/completions/tanuki_bot_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Gitlab::Llm::Anthropic::Completions::TanukiBot, feature_category: :duo_chat do - let_it_be(:user) { create(:user) } - - let(:question) { 'A question' } - let(:options) { { question: question } } - let(:template_class) { ::Gitlab::Llm::Anthropic::Templates::TanukiBot } - let(:tracking_context) { { request_id: 'uuid', action: :tanuki_bot } } - - let(:ai_response) do - instance_double(Gitlab::Llm::Anthropic::ResponseModifiers::TanukiBot, response_body: "text", errors: [], extras: {}) - end - - let(:prompt_message) do - build(:ai_message, :tanuki_bot, user: user, resource: user, request_id: 'uuid') - end - - subject(:tanuki_bot) { described_class.new(prompt_message, template_class, options).execute } - - describe '#execute' do - let(:tanuki_instance) { instance_double(::Gitlab::Llm::TanukiBot) } - - it 'makes a call to ::Gitlab::Llm::TanukiBot' do - expect(::Gitlab::Llm::TanukiBot).to receive(:new) - .with(current_user: user, question: question, tracking_context: tracking_context).and_return(tanuki_instance) - expect(tanuki_instance).to receive(:execute).and_return(ai_response) - - tanuki_bot - end - - it 'calls ResponseService' do - allow(::Gitlab::Llm::TanukiBot).to receive(:new) - .with(current_user: user, question: question, tracking_context: tracking_context).and_return(tanuki_instance) - allow(tanuki_instance).to receive(:execute).and_return(ai_response) - - response_modifier = ai_response - response_service = double - params = [user, user, response_modifier, { options: { request_id: 'uuid', ai_action: :tanuki_bot } }] - - expect(::Gitlab::Llm::GraphqlSubscriptionResponseService).to receive(:new).with(*params).and_return( - response_service - ) - expect(response_service).to receive(:execute) - - tanuki_bot - end - - it 'handles nil responses' do - allow(::Gitlab::Llm::TanukiBot).to receive(:execute).and_return( - Gitlab::Llm::ResponseModifiers::EmptyResponseModifier.new(nil) - ) - - expect { tanuki_bot }.not_to raise_error - end - end -end diff --git a/ee/spec/services/llm/tanuki_bot_service_spec.rb b/ee/spec/services/llm/tanuki_bot_service_spec.rb deleted file mode 100644 index cbe89b647b896..0000000000000 --- a/ee/spec/services/llm/tanuki_bot_service_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Llm::TanukiBotService, :saas, feature_category: :global_search do - let_it_be(:user) { create(:user) } - - let_it_be(:options) { { question: 'A question' } } - - subject { described_class.new(user, user, options) } - - before do - stub_licensed_features(ai_tanuki_bot: true) - end - - describe '#perform' do - let(:resource) { user } - let(:action_name) { :tanuki_bot } - let(:content) { options[:question] } - - before do - allow(user).to receive(:any_group_with_ai_available?).and_return(true) - end - - it_behaves_like 'schedules completion worker' - - context 'when ai_global_switch feature flag is disabled' do - before do - stub_feature_flags(ai_global_switch: false) - end - - it 'returns an error' do - expect(Llm::CompletionWorker).not_to receive(:perform_for) - - expect(subject.execute).to be_error - end - end - - context 'when tanuki_bot licensed feature is disabled' do - before do - stub_licensed_features(ai_tanuki_bot: false) - end - - it 'returns an error' do - expect(Llm::CompletionWorker).not_to receive(:perform_for) - - expect(subject.execute).to be_error - end - end - end -end diff --git a/rubocop/rubocop-code_reuse.yml b/rubocop/rubocop-code_reuse.yml index 2bd3339368da8..6f9d7902dc681 100644 --- a/rubocop/rubocop-code_reuse.yml +++ b/rubocop/rubocop-code_reuse.yml @@ -42,5 +42,4 @@ CodeReuse/ActiveRecord: - ee/db/fixtures/**/*.rb - ee/lib/tasks/**/*.rake - ee/lib/ee/gitlab/background_migration/**/*.rb - - ee/lib/gitlab/llm/open_ai/response_modifiers/tanuki_bot.rb - ee/lib/gitlab/usage/metrics/instrumentations/**/*.rb -- GitLab