FEATURE: Stream topic summaries. (#23065)

When we receive the stream parameter, we'll queue a job that periodically publishes partial updates, and after the summarization finishes, a final one with the completed version, plus metadata.

`summary-box` listens to these updates via MessageBus, and updates state accordingly.
This commit is contained in:
Roman Rizzi
2023-08-11 15:08:49 -03:00
committed by GitHub
parent 840bea3c51
commit 7ca5ee6cd2
13 changed files with 370 additions and 127 deletions

View File

@ -5508,9 +5508,9 @@ RSpec.describe TopicsController do
describe "#summary" do
fab!(:topic) { Fabricate(:topic) }
let(:plugin) { Plugin::Instance.new }
let(:strategy) { DummyCustomSummarization.new({ summary: "dummy", chunks: [] }) }
before do
strategy = DummyCustomSummarization.new("dummy")
plugin.register_summarization_strategy(strategy)
SiteSetting.summarization_strategy = strategy.model
end
@ -5536,14 +5536,17 @@ RSpec.describe TopicsController do
expect(response.status).to eq(200)
summary = response.parsed_body
expect(summary["summary"]).to eq(section.summarized_text)
expect(summary.dig("topic_summary", "summarized_text")).to eq(section.summarized_text)
end
end
context "when the user is a member of an allowlisted group" do
fab!(:user) { Fabricate(:leader) }
before { sign_in(user) }
before do
sign_in(user)
Group.find(Group::AUTO_GROUPS[:trust_level_3]).add(user)
end
it "returns a 404 if there is no topic" do
invalid_topic_id = 999
@ -5560,6 +5563,20 @@ RSpec.describe TopicsController do
expect(response.status).to eq(403)
end
it "returns a summary" do
get "/t/#{topic.id}/strategy-summary.json"
expect(response.status).to eq(200)
summary = response.parsed_body["topic_summary"]
section = SummarySection.last
expect(summary["summarized_text"]).to eq(section.summarized_text)
expect(summary["algorithm"]).to eq(strategy.model)
expect(summary["outdated"]).to eq(false)
expect(summary["can_regenerate"]).to eq(true)
expect(summary["new_posts_since_summary"]).to be_zero
end
end
context "when the user is not a member of an allowlisted group" do
@ -5587,7 +5604,7 @@ RSpec.describe TopicsController do
expect(response.status).to eq(200)
summary = response.parsed_body
expect(summary["summary"]).to eq(section.summarized_text)
expect(summary.dig("topic_summary", "summarized_text")).to eq(section.summarized_text)
end
end
end