FEATURE: Setting to control per post embeddings (#439)
* FEATURE: Setting to control per post embeddings
This commit is contained in:
parent
797f5971b6
commit
04bc402aae
|
@ -65,6 +65,8 @@ module Jobs
|
||||||
|
|
||||||
return if rebaked >= limit
|
return if rebaked >= limit
|
||||||
|
|
||||||
|
return unless SiteSetting.ai_embeddings_per_post_enabled
|
||||||
|
|
||||||
# Now for posts
|
# Now for posts
|
||||||
table_name = vector_rep.post_table_name
|
table_name = vector_rep.post_table_name
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,7 @@ discourse_ai:
|
||||||
- multilingual-e5-large
|
- multilingual-e5-large
|
||||||
- bge-large-en
|
- bge-large-en
|
||||||
- gemini
|
- gemini
|
||||||
|
ai_embeddings_per_post_enabled: false
|
||||||
ai_embeddings_generate_for_pms: false
|
ai_embeddings_generate_for_pms: false
|
||||||
ai_embeddings_semantic_related_topics_enabled:
|
ai_embeddings_semantic_related_topics_enabled:
|
||||||
default: false
|
default: false
|
||||||
|
|
|
@ -44,7 +44,8 @@ module DiscourseAi
|
||||||
# embeddings generation.
|
# embeddings generation.
|
||||||
callback =
|
callback =
|
||||||
Proc.new do |target|
|
Proc.new do |target|
|
||||||
if SiteSetting.ai_embeddings_enabled
|
if SiteSetting.ai_embeddings_enabled &&
|
||||||
|
(target.is_a?(Topic) || SiteSetting.ai_embeddings_per_post_enabled)
|
||||||
Jobs.enqueue(
|
Jobs.enqueue(
|
||||||
:generate_embeddings,
|
:generate_embeddings,
|
||||||
target_id: target.id,
|
target_id: target.id,
|
||||||
|
|
|
@ -16,10 +16,16 @@ describe DiscourseAi::Embeddings::EntryPoint do
|
||||||
it "queues a job on create if embeddings is enabled" do
|
it "queues a job on create if embeddings is enabled" do
|
||||||
SiteSetting.ai_embeddings_enabled = true
|
SiteSetting.ai_embeddings_enabled = true
|
||||||
|
|
||||||
expect { creator.create }.to change(Jobs::GenerateEmbeddings.jobs, :size).by(2) # topic_created and post_created
|
expect { creator.create }.to change(Jobs::GenerateEmbeddings.jobs, :size).by(1) # topic_created
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does nothing if sentiment analysis is disabled" do
|
it "queues two jobs on create if embeddings is enabled" do
|
||||||
|
SiteSetting.ai_embeddings_enabled = true
|
||||||
|
|
||||||
|
expect { creator.create }.to change(Jobs::GenerateEmbeddings.jobs, :size).by(1) # topic_created AND post_created
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does nothing if embeddings analysis is disabled" do
|
||||||
SiteSetting.ai_embeddings_enabled = false
|
SiteSetting.ai_embeddings_enabled = false
|
||||||
|
|
||||||
expect { creator.create }.not_to change(Jobs::GenerateEmbeddings.jobs, :size)
|
expect { creator.create }.not_to change(Jobs::GenerateEmbeddings.jobs, :size)
|
||||||
|
|
Loading…
Reference in New Issue