From 8d3638dad0433c898d8dec0894c9c9ad2b72d662 Mon Sep 17 00:00:00 2001 From: Michael Thomas <micthomas@gitlab.com> Date: Thu, 18 Apr 2024 14:11:43 +0000 Subject: [PATCH] Remove OpenAI workhorse and API key references --- .../helpers/ee/application_settings_helper.rb | 1 - ee/lib/ee/api/helpers/settings_helpers.rb | 1 - ee/lib/gitlab/llm/open_ai/workhorse.rb | 26 ------------------- .../ee/application_settings_helper_spec.rb | 4 --- ee/spec/requests/api/settings_spec.rb | 9 ------- 5 files changed, 41 deletions(-) delete mode 100644 ee/lib/gitlab/llm/open_ai/workhorse.rb diff --git a/ee/app/helpers/ee/application_settings_helper.rb b/ee/app/helpers/ee/application_settings_helper.rb index faa63c87fe006..3867744e99835 100644 --- a/ee/app/helpers/ee/application_settings_helper.rb +++ b/ee/app/helpers/ee/application_settings_helper.rb @@ -68,7 +68,6 @@ def visible_attributes :product_analytics_configurator_connection_string, :cube_api_base_url, :cube_api_key, - :openai_api_key, :security_policy_global_group_approvers_enabled, :security_approval_policies_limit, :anthropic_api_key, diff --git a/ee/lib/ee/api/helpers/settings_helpers.rb b/ee/lib/ee/api/helpers/settings_helpers.rb index 3ccf4b0e349cb..52adeb136ff6e 100644 --- a/ee/lib/ee/api/helpers/settings_helpers.rb +++ b/ee/lib/ee/api/helpers/settings_helpers.rb @@ -62,7 +62,6 @@ module SettingsHelpers optional :git_rate_limit_users_allowlist, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'List of usernames excluded from Git anti-abuse rate limits' optional :git_rate_limit_users_alertlist, type: Array[Integer], desc: 'List of user ids who will be emailed when Git abuse rate limit is exceeded' optional :auto_ban_user_on_excessive_projects_download, type: Grape::API::Boolean, desc: 'Ban users from the application when they exceed maximum number of unique projects download in the specified time period' - optional :openai_api_key, type: String, desc: "OpenAI API key" optional :anthropic_api_key, type: String, desc: "Anthropic API key" optional :make_profile_private, type: Grape::API::Boolean, desc: 'Flag indicating if users are permitted to make their profiles private' optional :service_access_tokens_expiration_enforced, type: Grape::API::Boolean, desc: "To enforce token expiration for Service accounts users" diff --git a/ee/lib/gitlab/llm/open_ai/workhorse.rb b/ee/lib/gitlab/llm/open_ai/workhorse.rb deleted file mode 100644 index 5994f87f46ce8..0000000000000 --- a/ee/lib/gitlab/llm/open_ai/workhorse.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Llm - module OpenAi - class Workhorse - OPEN_AI_API_URL = "https://api.openai.com/v1" - CHAT_URL = "#{OPEN_AI_API_URL}/chat/completions".freeze - - class << self - def default_headers - { - 'Authorization' => ["Bearer #{::Gitlab::CurrentSettings.openai_api_key}"], - 'Content-Type' => ['application/json'] - } - end - - def chat_response(options:) - Gitlab::Workhorse.send_url(CHAT_URL, - body: options.to_json, headers: default_headers, method: "POST") - end - end - end - end - end -end diff --git a/ee/spec/helpers/ee/application_settings_helper_spec.rb b/ee/spec/helpers/ee/application_settings_helper_spec.rb index 0594c57d80b0b..04010b0e00481 100644 --- a/ee/spec/helpers/ee/application_settings_helper_spec.rb +++ b/ee/spec/helpers/ee/application_settings_helper_spec.rb @@ -8,10 +8,6 @@ expect(visible_attributes).to include(*%i[max_personal_access_token_lifetime]) end - it 'contains openai_api_key value' do - expect(visible_attributes).to include(*%i[openai_api_key]) - end - it 'contains anthropic_api_key value' do expect(visible_attributes).to include(*%i[anthropic_api_key]) end diff --git a/ee/spec/requests/api/settings_spec.rb b/ee/spec/requests/api/settings_spec.rb index a83d9f5f1ac49..4c7ef8feff19b 100644 --- a/ee/spec/requests/api/settings_spec.rb +++ b/ee/spec/requests/api/settings_spec.rb @@ -168,15 +168,6 @@ end end - context 'openai api key setting' do - it 'updates openai_api_key' do - put api('/application/settings', admin, admin_mode: true), params: { openai_api_key: 'OPENAI_API_KEY' } - - expect(response).to have_gitlab_http_status(:ok) - expect(json_response['openai_api_key']).to eq('OPENAI_API_KEY') - end - end - context 'anthropic api key setting' do it 'updates anthropic_api_key' do put api('/application/settings', admin, admin_mode: true), params: { anthropic_api_key: 'ANTHROPIC_API_KEY' } -- GitLab