diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 023ab611..6efa5dc9 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -251,12 +251,3 @@ en: configuration_hint: one: "Make sure the `%{settings}` setting was configured." other: "Make sure these settings were configured: %{settings}" - - embeddings: - configuration: - disable_embeddings: "You have to disable 'ai embeddings enabled' first." - choose_model: "Set 'ai embeddings model' first." - model_unreachable: "We failed to generate a test embedding with this model. Check your settings are correct." - hint: - one: "Make sure the `%{settings}` setting was configured." - other: "Make sure the settings of the provider you want were configured. Options are: %{settings}" diff --git a/config/settings.yml b/config/settings.yml index 1aba523c..b933477b 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -216,7 +216,6 @@ discourse_ai: ai_embeddings_enabled: default: false client: true - validator: "DiscourseAi::Configuration::EmbeddingsDependencyValidator" ai_embeddings_discourse_service_api_endpoint: "" ai_embeddings_discourse_service_api_endpoint_srv: default: "" @@ -226,10 +225,17 @@ discourse_ai: secret: true ai_embeddings_model: type: enum - default: "" + list_type: compact + default: "bge-large-en" allow_any: false - enum: "DiscourseAi::Configuration::EmbeddingsModelEnumerator" - validator: "DiscourseAi::Configuration::EmbeddingsModelValidator" + choices: + - all-mpnet-base-v2 + - text-embedding-ada-002 + - text-embedding-3-small + - text-embedding-3-large + - multilingual-e5-large + - bge-large-en + - gemini ai_embeddings_per_post_enabled: default: false hidden: true diff --git a/lib/configuration/embeddings_dependency_validator.rb b/lib/configuration/embeddings_dependency_validator.rb deleted file mode 100644 index 88244d18..00000000 --- a/lib/configuration/embeddings_dependency_validator.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module DiscourseAi - module Configuration - class EmbeddingsDependencyValidator - def initialize(opts = {}) - @opts = opts - end - - def valid_value?(val) - return true if val == "f" - - SiteSetting.ai_embeddings_model.present? - end - - def error_message - I18n.t("discourse_ai.embeddings.configuration.choose_model") - end - end - end -end diff --git a/lib/configuration/embeddings_model_enumerator.rb b/lib/configuration/embeddings_model_enumerator.rb deleted file mode 100644 index 51e8a14a..00000000 --- a/lib/configuration/embeddings_model_enumerator.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require "enum_site_setting" - -module DiscourseAi - module Configuration - class EmbeddingsModelEnumerator < ::EnumSiteSetting - def self.valid_value?(val) - true - end - - def self.values - %w[ - all-mpnet-base-v2 - text-embedding-ada-002 - text-embedding-3-small - text-embedding-3-large - multilingual-e5-large - bge-large-en - gemini - ] - end - end - end -end diff --git a/lib/configuration/embeddings_model_validator.rb b/lib/configuration/embeddings_model_validator.rb deleted file mode 100644 index c77a956d..00000000 --- a/lib/configuration/embeddings_model_validator.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -module DiscourseAi - module Configuration - class EmbeddingsModelValidator - def initialize(opts = {}) - @opts = opts - end - - def valid_value?(val) - if val == "" - @embeddings_enabled = SiteSetting.ai_embeddings_enabled - return !@embeddings_enabled - end - - representation = - DiscourseAi::Embeddings::VectorRepresentations::Base.find_representation(val) - - return false if representation.nil? - - # Skip config for tests. We stub embeddings generation anyway. - return true if Rails.env.test? && val - - if !representation.correctly_configured? - @representation = representation - return false - end - - if !can_generate_embeddings?(val) - @unreachable = true - return false - end - - true - end - - def error_message - if @embeddings_enabled - return(I18n.t("discourse_ai.embeddings.configuration.disable_embeddings")) - end - - return(I18n.t("discourse_ai.embeddings.configuration.model_unreachable")) if @unreachable - - @representation&.configuration_hint - end - - def can_generate_embeddings?(val) - DiscourseAi::Embeddings::VectorRepresentations::Base - .find_representation(val) - .new(DiscourseAi::Embeddings::Strategies::Truncation.new) - .vector_from("this is a test") - .present? - end - end - end -end diff --git a/lib/embeddings/vector_representations/all_mpnet_base_v2.rb b/lib/embeddings/vector_representations/all_mpnet_base_v2.rb index 5d5793f2..a8bbe86c 100644 --- a/lib/embeddings/vector_representations/all_mpnet_base_v2.rb +++ b/lib/embeddings/vector_representations/all_mpnet_base_v2.rb @@ -4,34 +4,19 @@ module DiscourseAi module Embeddings module VectorRepresentations class AllMpnetBaseV2 < Base - class << self - def name - "all-mpnet-base-v2" - end - - def correctly_configured? - SiteSetting.ai_embeddings_discourse_service_api_endpoint_srv.present? || - SiteSetting.ai_embeddings_discourse_service_api_endpoint.present? - end - - def dependant_setting_names - %w[ - ai_embeddings_discourse_service_api_key - ai_embeddings_discourse_service_api_endpoint_srv - ai_embeddings_discourse_service_api_endpoint - ] - end - end - def vector_from(text) DiscourseAi::Inference::DiscourseClassifier.perform!( "#{discourse_embeddings_endpoint}/api/v1/classify", - self.class.name, + name, text, SiteSetting.ai_embeddings_discourse_service_api_key, ) end + def name + "all-mpnet-base-v2" + end + def dimensions 768 end diff --git a/lib/embeddings/vector_representations/base.rb b/lib/embeddings/vector_representations/base.rb index fc944cf0..58226913 100644 --- a/lib/embeddings/vector_representations/base.rb +++ b/lib/embeddings/vector_representations/base.rb @@ -4,41 +4,18 @@ module DiscourseAi module Embeddings module VectorRepresentations class Base - class << self - def find_representation(model_name) - # we are explicit here cause the loader may have not - # loaded the subclasses yet - [ - DiscourseAi::Embeddings::VectorRepresentations::AllMpnetBaseV2, - DiscourseAi::Embeddings::VectorRepresentations::BgeLargeEn, - DiscourseAi::Embeddings::VectorRepresentations::Gemini, - DiscourseAi::Embeddings::VectorRepresentations::MultilingualE5Large, - DiscourseAi::Embeddings::VectorRepresentations::TextEmbeddingAda002, - DiscourseAi::Embeddings::VectorRepresentations::TextEmbedding3Small, - DiscourseAi::Embeddings::VectorRepresentations::TextEmbedding3Large, - ].find { _1.name == model_name } - end - - def current_representation(strategy) - find_representation(SiteSetting.ai_embeddings_model).new(strategy) - end - - def correctly_configured? - raise NotImplementedError - end - - def dependant_setting_names - raise NotImplementedError - end - - def configuration_hint - settings = dependant_setting_names - I18n.t( - "discourse_ai.embeddings.configuration.hint", - settings: settings.join(", "), - count: settings.length, - ) - end + def self.current_representation(strategy) + # we are explicit here cause the loader may have not + # loaded the subclasses yet + [ + DiscourseAi::Embeddings::VectorRepresentations::AllMpnetBaseV2, + DiscourseAi::Embeddings::VectorRepresentations::BgeLargeEn, + DiscourseAi::Embeddings::VectorRepresentations::Gemini, + DiscourseAi::Embeddings::VectorRepresentations::MultilingualE5Large, + DiscourseAi::Embeddings::VectorRepresentations::TextEmbeddingAda002, + DiscourseAi::Embeddings::VectorRepresentations::TextEmbedding3Small, + DiscourseAi::Embeddings::VectorRepresentations::TextEmbedding3Large, + ].map { _1.new(strategy) }.find { _1.name == SiteSetting.ai_embeddings_model } end def initialize(strategy) diff --git a/lib/embeddings/vector_representations/bge_large_en.rb b/lib/embeddings/vector_representations/bge_large_en.rb index cf7adec4..f3e24c48 100644 --- a/lib/embeddings/vector_representations/bge_large_en.rb +++ b/lib/embeddings/vector_representations/bge_large_en.rb @@ -4,32 +4,6 @@ module DiscourseAi module Embeddings module VectorRepresentations class BgeLargeEn < Base - class << self - def name - "bge-large-en" - end - - def correctly_configured? - SiteSetting.ai_cloudflare_workers_api_token.present? || - DiscourseAi::Inference::HuggingFaceTextEmbeddings.configured? || - ( - SiteSetting.ai_embeddings_discourse_service_api_endpoint_srv.present? || - SiteSetting.ai_embeddings_discourse_service_api_endpoint.present? - ) - end - - def dependant_setting_names - %w[ - ai_cloudflare_workers_api_token - ai_hugging_face_tei_endpoint_srv - ai_hugging_face_tei_endpoint - ai_embeddings_discourse_service_api_key - ai_embeddings_discourse_service_api_endpoint_srv - ai_embeddings_discourse_service_api_endpoint - ] - end - end - def vector_from(text) if SiteSetting.ai_cloudflare_workers_api_token.present? DiscourseAi::Inference::CloudflareWorkersAi @@ -51,6 +25,10 @@ module DiscourseAi end end + def name + "bge-large-en" + end + def inference_model_name "baai/bge-large-en-v1.5" end diff --git a/lib/embeddings/vector_representations/gemini.rb b/lib/embeddings/vector_representations/gemini.rb index 529f5ac4..4b75da49 100644 --- a/lib/embeddings/vector_representations/gemini.rb +++ b/lib/embeddings/vector_representations/gemini.rb @@ -4,20 +4,6 @@ module DiscourseAi module Embeddings module VectorRepresentations class Gemini < Base - class << self - def name - "gemini" - end - - def correctly_configured? - SiteSetting.ai_gemini_api_key.present? - end - - def dependant_setting_names - %w[ai_gemini_api_key] - end - end - def id 5 end @@ -26,6 +12,10 @@ module DiscourseAi 1 end + def name + "gemini" + end + def dimensions 768 end diff --git a/lib/embeddings/vector_representations/multilingual_e5_large.rb b/lib/embeddings/vector_representations/multilingual_e5_large.rb index 59133263..55dfc448 100644 --- a/lib/embeddings/vector_representations/multilingual_e5_large.rb +++ b/lib/embeddings/vector_representations/multilingual_e5_large.rb @@ -4,30 +4,6 @@ module DiscourseAi module Embeddings module VectorRepresentations class MultilingualE5Large < Base - class << self - def name - "multilingual-e5-large" - end - - def correctly_configured? - DiscourseAi::Inference::HuggingFaceTextEmbeddings.configured? || - ( - SiteSetting.ai_embeddings_discourse_service_api_endpoint_srv.present? || - SiteSetting.ai_embeddings_discourse_service_api_endpoint.present? - ) - end - - def dependant_setting_names - %w[ - ai_hugging_face_tei_endpoint_srv - ai_hugging_face_tei_endpoint - ai_embeddings_discourse_service_api_key - ai_embeddings_discourse_service_api_endpoint_srv - ai_embeddings_discourse_service_api_endpoint - ] - end - end - def vector_from(text) if DiscourseAi::Inference::HuggingFaceTextEmbeddings.configured? truncated_text = tokenizer.truncate(text, max_sequence_length - 2) @@ -35,7 +11,7 @@ module DiscourseAi elsif discourse_embeddings_endpoint.present? DiscourseAi::Inference::DiscourseClassifier.perform!( "#{discourse_embeddings_endpoint}/api/v1/classify", - self.class.name, + name, "query: #{text}", SiteSetting.ai_embeddings_discourse_service_api_key, ) @@ -52,6 +28,10 @@ module DiscourseAi 1 end + def name + "multilingual-e5-large" + end + def dimensions 1024 end diff --git a/lib/embeddings/vector_representations/text_embedding_3_large.rb b/lib/embeddings/vector_representations/text_embedding_3_large.rb index f7d478bf..ab88b238 100644 --- a/lib/embeddings/vector_representations/text_embedding_3_large.rb +++ b/lib/embeddings/vector_representations/text_embedding_3_large.rb @@ -4,20 +4,6 @@ module DiscourseAi module Embeddings module VectorRepresentations class TextEmbedding3Large < Base - class << self - def name - "text-embedding-3-large" - end - - def correctly_configured? - SiteSetting.ai_openai_api_key.present? - end - - def dependant_setting_names - %w[ai_openai_api_key] - end - end - def id 7 end @@ -26,6 +12,10 @@ module DiscourseAi 1 end + def name + "text-embedding-3-large" + end + def dimensions # real dimentions are 3072, but we only support up to 2000 in the # indexes, so we downsample to 2000 via API @@ -48,7 +38,7 @@ module DiscourseAi response = DiscourseAi::Inference::OpenAiEmbeddings.perform!( text, - model: self.clas.name, + model: name, dimensions: dimensions, ) response[:data].first[:embedding] diff --git a/lib/embeddings/vector_representations/text_embedding_3_small.rb b/lib/embeddings/vector_representations/text_embedding_3_small.rb index 842ed183..a32544d9 100644 --- a/lib/embeddings/vector_representations/text_embedding_3_small.rb +++ b/lib/embeddings/vector_representations/text_embedding_3_small.rb @@ -4,20 +4,6 @@ module DiscourseAi module Embeddings module VectorRepresentations class TextEmbedding3Small < Base - class << self - def name - "text-embedding-3-small" - end - - def correctly_configured? - SiteSetting.ai_openai_api_key.present? - end - - def dependant_setting_names - %w[ai_openai_api_key] - end - end - def id 6 end @@ -26,6 +12,10 @@ module DiscourseAi 1 end + def name + "text-embedding-3-small" + end + def dimensions 1536 end @@ -43,7 +33,7 @@ module DiscourseAi end def vector_from(text) - response = DiscourseAi::Inference::OpenAiEmbeddings.perform!(text, model: self.class.name) + response = DiscourseAi::Inference::OpenAiEmbeddings.perform!(text, model: name) response[:data].first[:embedding] end diff --git a/lib/embeddings/vector_representations/text_embedding_ada_002.rb b/lib/embeddings/vector_representations/text_embedding_ada_002.rb index a5bbe1ac..2bce079b 100644 --- a/lib/embeddings/vector_representations/text_embedding_ada_002.rb +++ b/lib/embeddings/vector_representations/text_embedding_ada_002.rb @@ -4,20 +4,6 @@ module DiscourseAi module Embeddings module VectorRepresentations class TextEmbeddingAda002 < Base - class << self - def name - "text-embedding-ada-002" - end - - def correctly_configured? - SiteSetting.ai_openai_api_key.present? - end - - def dependant_setting_names - %w[ai_openai_api_key] - end - end - def id 2 end @@ -26,6 +12,10 @@ module DiscourseAi 1 end + def name + "text-embedding-ada-002" + end + def dimensions 1536 end @@ -43,7 +33,7 @@ module DiscourseAi end def vector_from(text) - response = DiscourseAi::Inference::OpenAiEmbeddings.perform!(text, model: self.class.name) + response = DiscourseAi::Inference::OpenAiEmbeddings.perform!(text, model: name) response[:data].first[:embedding] end diff --git a/spec/jobs/scheduled/embeddings_backfill_spec.rb b/spec/jobs/scheduled/embeddings_backfill_spec.rb index 45b90262..74cec6dc 100644 --- a/spec/jobs/scheduled/embeddings_backfill_spec.rb +++ b/spec/jobs/scheduled/embeddings_backfill_spec.rb @@ -25,7 +25,6 @@ RSpec.describe Jobs::EmbeddingsBackfill do end it "backfills topics based on bumped_at date" do - SiteSetting.ai_embeddings_model = "bge-large-en" SiteSetting.ai_embeddings_enabled = true SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com" SiteSetting.ai_embeddings_backfill_batch_size = 1 diff --git a/spec/lib/modules/ai_bot/tools/search_spec.rb b/spec/lib/modules/ai_bot/tools/search_spec.rb index 3e2d5c7a..066937c3 100644 --- a/spec/lib/modules/ai_bot/tools/search_spec.rb +++ b/spec/lib/modules/ai_bot/tools/search_spec.rb @@ -70,7 +70,6 @@ RSpec.describe DiscourseAi::AiBot::Tools::Search do SiteSetting.ai_embeddings_semantic_search_hyde_model = "fake:fake" SiteSetting.ai_embeddings_semantic_search_enabled = true SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com" - SiteSetting.ai_embeddings_model = "bge-large-en" hyde_embedding = [0.049382, 0.9999] EmbeddingsGenerationStubs.discourse_service( diff --git a/spec/lib/modules/embeddings/entry_point_spec.rb b/spec/lib/modules/embeddings/entry_point_spec.rb index 3571813d..de1e3024 100644 --- a/spec/lib/modules/embeddings/entry_point_spec.rb +++ b/spec/lib/modules/embeddings/entry_point_spec.rb @@ -13,8 +13,6 @@ describe DiscourseAi::Embeddings::EntryPoint do ) end - before { SiteSetting.ai_embeddings_model = "bge-large-en" } - it "queues a job on create if embeddings is enabled" do SiteSetting.ai_embeddings_enabled = true diff --git a/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rb b/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rb index fe5bbcd5..78aee2ae 100644 --- a/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rb +++ b/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rb @@ -6,8 +6,8 @@ RSpec.describe Jobs::GenerateEmbeddings do describe "#execute" do before do SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com" - SiteSetting.ai_embeddings_model = "bge-large-en" SiteSetting.ai_embeddings_enabled = true + SiteSetting.ai_embeddings_model = "bge-large-en" end fab!(:topic) { Fabricate(:topic) } @@ -27,7 +27,7 @@ RSpec.describe Jobs::GenerateEmbeddings do vector_rep.tokenizer, vector_rep.max_sequence_length - 2, ) - EmbeddingsGenerationStubs.discourse_service(vector_rep.class.name, text, expected_embedding) + EmbeddingsGenerationStubs.discourse_service(vector_rep.name, text, expected_embedding) job.execute(target_id: topic.id, target_type: "Topic") @@ -39,7 +39,7 @@ RSpec.describe Jobs::GenerateEmbeddings do text = truncation.prepare_text_from(post, vector_rep.tokenizer, vector_rep.max_sequence_length - 2) - EmbeddingsGenerationStubs.discourse_service(vector_rep.class.name, text, expected_embedding) + EmbeddingsGenerationStubs.discourse_service(vector_rep.name, text, expected_embedding) job.execute(target_id: post.id, target_type: "Post") diff --git a/spec/lib/modules/embeddings/semantic_related_spec.rb b/spec/lib/modules/embeddings/semantic_related_spec.rb index fd3677a0..37965aa1 100644 --- a/spec/lib/modules/embeddings/semantic_related_spec.rb +++ b/spec/lib/modules/embeddings/semantic_related_spec.rb @@ -13,10 +13,7 @@ describe DiscourseAi::Embeddings::SemanticRelated do fab!(:secured_category_topic) { Fabricate(:topic, category: secured_category) } fab!(:closed_topic) { Fabricate(:topic, closed: true) } - before do - SiteSetting.ai_embeddings_model = "bge-large-en" - SiteSetting.ai_embeddings_semantic_related_topics_enabled = true - end + before { SiteSetting.ai_embeddings_semantic_related_topics_enabled = true } describe "#related_topic_ids_for" do context "when embeddings do not exist" do diff --git a/spec/lib/modules/embeddings/semantic_search_spec.rb b/spec/lib/modules/embeddings/semantic_search_spec.rb index c2a73229..07df3821 100644 --- a/spec/lib/modules/embeddings/semantic_search_spec.rb +++ b/spec/lib/modules/embeddings/semantic_search_spec.rb @@ -14,7 +14,6 @@ RSpec.describe DiscourseAi::Embeddings::SemanticSearch do before do SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com" - SiteSetting.ai_embeddings_model = "bge-large-en" hyde_embedding = [0.049382, 0.9999] EmbeddingsGenerationStubs.discourse_service( diff --git a/spec/lib/modules/embeddings/semantic_topic_query_spec.rb b/spec/lib/modules/embeddings/semantic_topic_query_spec.rb index 05b1256e..7b7bb9e7 100644 --- a/spec/lib/modules/embeddings/semantic_topic_query_spec.rb +++ b/spec/lib/modules/embeddings/semantic_topic_query_spec.rb @@ -4,8 +4,6 @@ describe DiscourseAi::Embeddings::EntryPoint do fab!(:user) { Fabricate(:user) } describe "SemanticTopicQuery extension" do - before { SiteSetting.ai_embeddings_model = "bge-large-en" } - describe "#list_semantic_related_topics" do subject(:topic_query) { DiscourseAi::Embeddings::SemanticTopicQuery.new(user) } diff --git a/spec/lib/modules/embeddings/vector_representations/all_mpnet_base_v2_spec.rb b/spec/lib/modules/embeddings/vector_representations/all_mpnet_base_v2_spec.rb index c1cefe04..890e69c1 100644 --- a/spec/lib/modules/embeddings/vector_representations/all_mpnet_base_v2_spec.rb +++ b/spec/lib/modules/embeddings/vector_representations/all_mpnet_base_v2_spec.rb @@ -10,7 +10,7 @@ RSpec.describe DiscourseAi::Embeddings::VectorRepresentations::AllMpnetBaseV2 do before { SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com" } def stub_vector_mapping(text, expected_embedding) - EmbeddingsGenerationStubs.discourse_service(described_class.name, text, expected_embedding) + EmbeddingsGenerationStubs.discourse_service(vector_rep.name, text, expected_embedding) end it_behaves_like "generates and store embedding using with vector representation" diff --git a/spec/lib/modules/embeddings/vector_representations/multilingual_e5_large_spec.rb b/spec/lib/modules/embeddings/vector_representations/multilingual_e5_large_spec.rb index e7af5eba..01930028 100644 --- a/spec/lib/modules/embeddings/vector_representations/multilingual_e5_large_spec.rb +++ b/spec/lib/modules/embeddings/vector_representations/multilingual_e5_large_spec.rb @@ -11,7 +11,7 @@ RSpec.describe DiscourseAi::Embeddings::VectorRepresentations::MultilingualE5Lar def stub_vector_mapping(text, expected_embedding) EmbeddingsGenerationStubs.discourse_service( - described_class.name, + vector_rep.name, "query: #{text}", expected_embedding, ) diff --git a/spec/lib/modules/embeddings/vector_representations/text_embedding_ada_002_spec.rb b/spec/lib/modules/embeddings/vector_representations/text_embedding_ada_002_spec.rb index ed5a80fc..9d014cb4 100644 --- a/spec/lib/modules/embeddings/vector_representations/text_embedding_ada_002_spec.rb +++ b/spec/lib/modules/embeddings/vector_representations/text_embedding_ada_002_spec.rb @@ -8,7 +8,7 @@ RSpec.describe DiscourseAi::Embeddings::VectorRepresentations::TextEmbeddingAda0 let(:truncation) { DiscourseAi::Embeddings::Strategies::Truncation.new } def stub_vector_mapping(text, expected_embedding) - EmbeddingsGenerationStubs.openai_service(described_class.name, text, expected_embedding) + EmbeddingsGenerationStubs.openai_service(vector_rep.name, text, expected_embedding) end it_behaves_like "generates and store embedding using with vector representation" diff --git a/spec/system/ai_helper/ai_composer_helper_spec.rb b/spec/system/ai_helper/ai_composer_helper_spec.rb index ca66db96..dff111f6 100644 --- a/spec/system/ai_helper/ai_composer_helper_spec.rb +++ b/spec/system/ai_helper/ai_composer_helper_spec.rb @@ -327,10 +327,7 @@ RSpec.describe "AI Composer helper", type: :system, js: true do end context "when suggesting the category with AI category suggester" do - before do - SiteSetting.ai_embeddings_model = "bge-large-en" - SiteSetting.ai_embeddings_enabled = true - end + before { SiteSetting.ai_embeddings_enabled = true } it "updates the category with the suggested category" do response = @@ -355,10 +352,7 @@ RSpec.describe "AI Composer helper", type: :system, js: true do end context "when suggesting the tags with AI tag suggester" do - before do - SiteSetting.ai_embeddings_model = "bge-large-en" - SiteSetting.ai_embeddings_enabled = true - end + before { SiteSetting.ai_embeddings_enabled = true } it "updates the tag with the suggested tag" do response = diff --git a/spec/system/ai_helper/ai_split_topic_suggestion_spec.rb b/spec/system/ai_helper/ai_split_topic_suggestion_spec.rb index bc4508fb..b280a16a 100644 --- a/spec/system/ai_helper/ai_split_topic_suggestion_spec.rb +++ b/spec/system/ai_helper/ai_split_topic_suggestion_spec.rb @@ -80,10 +80,7 @@ RSpec.describe "AI Post helper", type: :system, js: true do end context "when suggesting categories with AI category suggester" do - before do - SiteSetting.ai_embeddings_model = "bge-large-en" - SiteSetting.ai_embeddings_enabled = true - end + before { SiteSetting.ai_embeddings_enabled = true } skip "TODO: Category suggester only loading one category in test" do it "updates the category with the suggested category" do @@ -111,10 +108,7 @@ RSpec.describe "AI Post helper", type: :system, js: true do end context "when suggesting tags with AI tag suggester" do - before do - SiteSetting.ai_embeddings_model = "bge-large-en" - SiteSetting.ai_embeddings_enabled = true - end + before { SiteSetting.ai_embeddings_enabled = true } it "update the tag with the suggested tag" do response = diff --git a/spec/system/embeddings/semantic_search_spec.rb b/spec/system/embeddings/semantic_search_spec.rb index 39bb0f48..af5b5708 100644 --- a/spec/system/embeddings/semantic_search_spec.rb +++ b/spec/system/embeddings/semantic_search_spec.rb @@ -11,7 +11,6 @@ RSpec.describe "AI Composer helper", type: :system, js: true do before do SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com" - SiteSetting.ai_embeddings_model = "bge-large-en" prompt = DiscourseAi::Embeddings::HydeGenerators::OpenAi.new.prompt(query) OpenAiCompletionsInferenceStubs.stub_response( prompt,