Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Embeddings validator test needs to use the new Vector class. #1041

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading