This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +20
-19
lines changed
javascripts/discourse/connectors/topic-list-main-link-bottom
stylesheets/modules/summarization/common
lib/modules/summarization Expand file tree Collapse file tree 8 files changed +20
-19
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,12 @@ class HotTopicsGistBatch < ::Jobs::Base
55 def execute ( args )
66 return if !SiteSetting . discourse_ai_enabled
77 return if !SiteSetting . ai_summarization_enabled
8- return if ! SiteSetting . ai_summarize_hot_topics_list
8+ return if SiteSetting . ai_summarize_max_hot_topics_gists_per_batch . zero?
99
1010 Topic
1111 . joins ( "JOIN topic_hot_scores on topics.id = topic_hot_scores.topic_id" )
1212 . order ( "topic_hot_scores.score DESC" )
13- . limit ( 100 )
13+ . limit ( SiteSetting . ai_summarize_max_hot_topics_gists_per_batch )
1414 . each do |topic |
1515 summarizer = DiscourseAi ::Summarization . topic_gist ( topic )
1616 gist = summarizer . existing_summary
Original file line number Diff line number Diff line change 11import Component from " @glimmer/component" ;
2- import icon from " discourse-common/helpers/d-icon" ;
32
43export default class AiTopicGist extends Component {
5- static shouldRender (outletArgs , helper ) {
4+ static shouldRender (outletArgs ) {
65 return outletArgs? .topic ? .ai_topic_gist && ! outletArgs .topic .excerpt ;
76 }
87
Original file line number Diff line number Diff line change 217217}
218218
219219.ai-topic-gist {
220- margin-top : .5em ;
220+ margin-top : 0 .5em ;
221221
222222 & __text {
223223 font-size : var (--font-down-2 );
224224 }
225- }
225+ }
Original file line number Diff line number Diff line change 8484 ai_summarization_model : " Model to use for summarization."
8585 ai_custom_summarization_allowed_groups : " Groups allowed to use create new summaries."
8686 ai_pm_summarization_allowed_groups : " Groups allowed to create and view summaries in PMs."
87- ai_summarize_hot_topics_list : " Display a brief summary for each topic in the hot topics list (if available). "
87+ ai_summarize_max_hot_topics_gists_per_batch : " After updating topics in the hot list, we'll generate brief summaries of the first N ones. (Disabled when 0) "
8888
8989 ai_bot_enabled : " Enable the AI Bot module."
9090 ai_bot_enable_chat_warning : " Display a warning when PM chat is initiated. Can be overriden by editing the translation string: discourse_ai.ai_bot.pm_warning"
Original file line number Diff line number Diff line change @@ -376,9 +376,10 @@ discourse_ai:
376376 type : group_list
377377 list_type : compact
378378 default : " 3|13" # 3: @staff, 13: @trust_level_3
379- ai_summarize_hot_topics_list :
380- client : true
381- default : false
379+ ai_summarize_max_hot_topics_gists_per_batch :
380+ default : 0
381+ min : 0
382+ max : 1000
382383 ai_summarization_strategy : # TODO(roman): Deprecated. Remove by Sept 2024
383384 type : enum
384385 default : " "
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def inject_into(plugin)
1919
2020 plugin . register_modifier ( :topic_query_create_list_topics ) do |topics , options |
2121 if options [ :filter ] == :hot && SiteSetting . ai_summarization_enabled &&
22- SiteSetting . ai_summarize_hot_topics_list
22+ SiteSetting . ai_summarize_max_hot_topics_gists_per_batch > 0
2323 topics . includes ( :ai_summaries ) . where (
2424 "ai_summaries.id IS NULL OR ai_summaries.summary_type = ?" ,
2525 AiSummary . summary_types [ :gist ] ,
@@ -33,7 +33,8 @@ def inject_into(plugin)
3333 :topic_list_item ,
3434 :ai_topic_gist ,
3535 include_condition : -> do
36- SiteSetting . ai_summarization_enabled && SiteSetting . ai_summarize_hot_topics_list
36+ SiteSetting . ai_summarization_enabled &&
37+ SiteSetting . ai_summarize_max_hot_topics_gists_per_batch > 0
3738 end ,
3839 ) { object . ai_summaries . to_a . first &.summarized_text }
3940
Original file line number Diff line number Diff line change 88 before do
99 assign_fake_provider_to ( :ai_summarization_model )
1010 SiteSetting . ai_summarization_enabled = true
11- SiteSetting . ai_summarize_hot_topics_list = true
11+ SiteSetting . ai_summarize_max_hot_topics_gists_per_batch = 100
1212 end
1313
1414 describe "#execute" do
15- context "When there is a topic with a hot score" do
15+ context "when there is a topic with a hot score" do
1616 before { TopicHotScore . create! ( topic_id : topic_1 . id , score : 0.1 ) }
1717
1818 it "does nothing if the plugin is disabled" do
3434 end
3535
3636 it "does nothing if hot topics summarization is disabled" do
37- SiteSetting . ai_summarize_hot_topics_list = false
37+ SiteSetting . ai_summarize_max_hot_topics_gists_per_batch = 0
3838
3939 subject . execute ( { } )
4040
4848 DiscourseAi ::Completions ::Llm . with_prepared_responses ( [ gist_result ] ) { subject . execute ( { } ) }
4949
5050 gist = AiSummary . gist . find_by ( target : topic_1 )
51- expect ( gist . summarized_text ) . to eq ( "I'm a gist" )
51+ expect ( gist . summarized_text ) . to eq ( gist_result )
5252 end
5353
54- context "and we already generated a gist of it" do
54+ context "when we already generated a gist of it" do
5555 fab! ( :ai_gist ) do
5656 Fabricate (
5757 :topic_ai_gist ,
Original file line number Diff line number Diff line change 1919
2020 describe "topic_query_create_list_topics modifier" do
2121 context "when hot topic summarization is enabled" do
22- before { SiteSetting . ai_summarize_hot_topics_list = true }
22+ before { SiteSetting . ai_summarize_max_hot_topics_gists_per_batch = 100 }
2323
2424 it "preloads only gist summaries" do
2525 gist_topic = topic_query . list_hot . topics . find { |t | t . id == topic_ai_gist . target_id }
4949 end
5050
5151 context "when hot topics summarization is enabled" do
52- before { SiteSetting . ai_summarize_hot_topics_list = true }
52+ before { SiteSetting . ai_summarize_max_hot_topics_gists_per_batch = 100 }
5353
5454 it "includes the summary" do
5555 gist_topic = topic_query . list_hot . topics . find { |t | t . id == topic_ai_gist . target_id }
You can’t perform that action at this time.
0 commit comments