- {{i18n "summary.summarized_on" date=this.summary.summarizedOn}}
-
-
- {{this.outdatedSummaryWarningText}} -
- {{/if}} -diff --git a/app/assets/javascripts/discourse/app/components/ai-summary-skeleton.hbs b/app/assets/javascripts/discourse/app/components/ai-summary-skeleton.hbs deleted file mode 100644 index 528b6460598..00000000000 --- a/app/assets/javascripts/discourse/app/components/ai-summary-skeleton.hbs +++ /dev/null @@ -1,28 +0,0 @@ -
- {{i18n "summary.summarized_on" date=this.summary.summarizedOn}}
-
-
- {{this.outdatedSummaryWarningText}} -
- {{/if}} -{{htmlSafe this.topRepliesSummaryInfo}}
+ {{/if}} +{{htmlSafe this.topRepliesSummaryInfo}}
+{{this.summary}}
-hello world new post :D
", - ) - - summarization.summarize(topic, user) - - first_post_data = - strategy.content[:contents].detect { |c| c[:id] == topic.first_post.post_number } - - expect(first_post_data[:text]).to eq(topic_embed.embed_content_cache) - end - end - end - - context "when the content was summarized in multiple chunks" do - let(:summary) do - { - summary: "This is the final summary", - chunks: [ - { ids: [topic.first_post.post_number], summary: "this is the first chunk" }, - { ids: [post_1.post_number, post_2.post_number], summary: "this is the second chunk" }, - ], - } - end - - it "caches the summary and each chunk" do - section = summarization.summarize(topic, user) - - expect(section.summarized_text).to eq(summary[:summary]) - - assert_summary_is_cached(topic, summary) - - summary[:chunks].each { |c| assert_chunk_is_cached(topic, c) } - end - end - - describe "invalidating cached summaries" do - let(:cached_text) { "This is a cached summary" } - let(:summarized_text) { "This is the final summary" } - let(:summary) do - { - summary: summarized_text, - chunks: [ - { ids: [topic.first_post.post_number], summary: "this is the first chunk" }, - { ids: [post_1.post_number, post_2.post_number], summary: "this is the second chunk" }, - ], - } - end - - def cached_summary - SummarySection.find_by(target: topic, meta_section_id: nil) - end - - before do - summarization.summarize(topic, user) - - cached_summary.update!(summarized_text: cached_text, created_at: 24.hours.ago) - end - - context "when the user can requests new summaries" do - context "when there are no new posts" do - it "returns the cached summary" do - section = summarization.summarize(topic, user) - - expect(section.summarized_text).to eq(cached_text) - end - end - - context "when there are new posts" do - before { cached_summary.update!(original_content_sha: "outdated_sha") } - - it "returns a new summary" do - section = summarization.summarize(topic, user) - - expect(section.summarized_text).to eq(summarized_text) - end - - context "when the cached summary is less than one hour old" do - before { cached_summary.update!(created_at: 30.minutes.ago) } - - it "returns the cached summary" do - cached_summary.update!(created_at: 30.minutes.ago) - - section = summarization.summarize(topic, user) - - expect(section.summarized_text).to eq(cached_text) - expect(section.outdated).to eq(true) - end - - it "returns a new summary if the skip_age_check flag is passed" do - section = summarization.summarize(topic, user, skip_age_check: true) - - expect(section.summarized_text).to eq(summarized_text) - end - end - end - end - end - - describe "stream partial updates" do - let(:summary) { { summary: "This is the final summary", chunks: [] } } - - it "receives a blk that is passed to the underlying strategy and called with partial summaries" do - partial_result = nil - - summarization.summarize(topic, user) { |partial_summary| partial_result = partial_summary } - - expect(partial_result).to eq(summary[:summary]) - end - end - end -end diff --git a/spec/support/dummy_custom_summarization.rb b/spec/support/dummy_custom_summarization.rb deleted file mode 100644 index 45fd1166524..00000000000 --- a/spec/support/dummy_custom_summarization.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -class DummyCustomSummarization < Summarization::Base - def initialize(summarization_result) - @summarization_result = summarization_result - end - - def display_name - "dummy" - end - - def correctly_configured? - true - end - - def configuration_hint - "hint" - end - - def model - "dummy" - end - - def summarize(content, _user) - @content = content - @summarization_result.tap { |result| yield(result[:summary]) if block_given? } - end - - attr_reader :content -end