Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit b378ea6

Browse files
committed
FEATURE: Adjustments to gist summaries
- makes visible to everyone by default - backfills gists before full summaries - adds configurable max age setting to backfill job
1 parent c533634 commit b378ea6

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

app/jobs/scheduled/summaries_backfill.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,26 @@ def execute(_args)
1212

1313
system_user = Discourse.system_user
1414

15+
if SiteSetting.ai_summary_gists_enabled
16+
gist_t = AiSummary.summary_types[:gist]
17+
backfill_candidates(gist_t)
18+
.limit(current_budget(gist_t))
19+
.each do |topic|
20+
DiscourseAi::Summarization.topic_gist(topic).force_summarize(system_user)
21+
end
22+
end
23+
1524
complete_t = AiSummary.summary_types[:complete]
1625
backfill_candidates(complete_t)
1726
.limit(current_budget(complete_t))
1827
.each do |topic|
1928
DiscourseAi::Summarization.topic_summary(topic).force_summarize(system_user)
2029
end
21-
22-
return unless SiteSetting.ai_summary_gists_enabled
23-
24-
gist_t = AiSummary.summary_types[:gist]
25-
backfill_candidates(gist_t)
26-
.limit(current_budget(gist_t))
27-
.each { |topic| DiscourseAi::Summarization.topic_gist(topic).force_summarize(system_user) }
2830
end
2931

3032
def backfill_candidates(summary_type)
33+
max_age_days = SiteSetting.ai_summary_backfill_topic_max_age_days
34+
3135
Topic
3236
.where("topics.word_count >= ?", SiteSetting.ai_summary_backfill_minimum_word_count)
3337
.joins(<<~SQL)
@@ -36,6 +40,7 @@ def backfill_candidates(summary_type)
3640
ais.target_type = 'Topic' AND
3741
ais.summary_type = '#{summary_type}'
3842
SQL
43+
.where("topics.created_at > current_timestamp - INTERVAL '#{max_age_days.to_i} DAY'")
3944
.where(
4045
"ais.id IS NULL OR UPPER(ais.content_range) < topics.highest_post_number + 1",
4146
) # (1..1) gets stored ad (1..2).

config/settings.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,17 @@ discourse_ai:
228228
ai_summary_gists_allowed_groups:
229229
type: group_list
230230
list_type: compact
231-
default: ""
232-
ai_summarization_strategy: # TODO(roman): Deprecated. Remove by Sept 2024
233-
type: enum
234-
default: ""
231+
default: "0" #everyone
235232
hidden: true
236-
choices: "DiscourseAi::Configuration::LlmEnumerator.old_summarization_options + ['']"
237233
ai_summarization_model_allowed_seeded_models:
238234
default: ""
239235
hidden: true
240236
type: list
241237
list_type: compact
238+
ai_summary_backfill_topic_max_age_days:
239+
default: 30
240+
min: 1
241+
max: 10000
242242
ai_summary_backfill_maximum_topics_per_hour:
243243
default: 0
244244
min: 0

spec/jobs/scheduled/summaries_backfill_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@
6464

6565
expect(subject.backfill_candidates(type).map(&:id)).to contain_exactly(topic_2.id, topic.id)
6666
end
67+
68+
it "respects max age setting" do
69+
SiteSetting.ai_summary_backfill_topic_max_age_days = 1
70+
topic.update!(created_at: 2.days.ago)
71+
72+
expect(subject.backfill_candidates(type)).to be_empty
73+
end
6774
end
6875

6976
describe "#execute" do

0 commit comments

Comments
 (0)