Skip to content

Commit

Permalink
FIX: Embeddings validator test needs to use the new Vector class. (#1041
Browse files Browse the repository at this point in the history
)
  • Loading branch information
romanrizzi authored Dec 23, 2024
1 parent bdb8f1d commit ceac6e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/configuration/embeddings_model_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ def error_message
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?
vdef = DiscourseAi::Embeddings::VectorRepresentations::Base.find_representation(val).new
DiscourseAi::Embeddings::Vector.new(vdef).vector_from("this is a test").present?
end
end
end
Expand Down
17 changes: 17 additions & 0 deletions spec/configuration/embeddings_model_validator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require_relative "../support/embeddings_generation_stubs"

RSpec.describe DiscourseAi::Configuration::EmbeddingsModelValidator do
before { SiteSetting.ai_embeddings_discourse_service_api_endpoint = "http://test.com" }

describe "#can_generate_embeddings?" do
it "works" do
discourse_model = "all-mpnet-base-v2"

EmbeddingsGenerationStubs.discourse_service(discourse_model, "this is a test", [1] * 1024)

expect(subject.can_generate_embeddings?(discourse_model)).to eq(true)
end
end
end

0 comments on commit ceac6e5

Please sign in to comment.