FIX: embedding validation (#1043)
This commit is contained in:
parent
792df58fbc
commit
47ecf86aa1
|
@ -42,8 +42,9 @@ module DiscourseAi
|
||||||
def can_generate_embeddings?(val)
|
def can_generate_embeddings?(val)
|
||||||
DiscourseAi::Embeddings::VectorRepresentations::Base
|
DiscourseAi::Embeddings::VectorRepresentations::Base
|
||||||
.find_representation(val)
|
.find_representation(val)
|
||||||
.new(DiscourseAi::Embeddings::Strategies::Truncation.new)
|
.new
|
||||||
.vector_from("this is a test")
|
.inference_client
|
||||||
|
.perform!("this is a test")
|
||||||
.present?
|
.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe DiscourseAi::Configuration::EmbeddingsModuleValidator do
|
||||||
|
let(:validator) { described_class.new }
|
||||||
|
|
||||||
|
describe "#can_generate_embeddings?" do
|
||||||
|
it "returns true if embeddings can be generated" do
|
||||||
|
stub_request(
|
||||||
|
:post,
|
||||||
|
"https://generativelanguage.googleapis.com/v1beta/models/embedding-001:embedContent?key=",
|
||||||
|
).to_return(status: 200, body: { embedding: { values: [1, 2, 3] } }.to_json)
|
||||||
|
expect(validator.can_generate_embeddings?("gemini")).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue