mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 14:22:40 +08:00
FEATURE: Inline topic summary. Cached version accessible to everyone. (#22551)
* FEATURE: Inline topic summary. Cached version accessible to everyone. Anons and non-members of the `custom_summarization_allowed_groups_map` groups can see cached summaries for any accessible topic. After the first 12 hours and if the posts to summarize have changed, allowed users clicking on the button will automatically re-generate it. * Ensure chat summaries work and prevent model hallucinations when there are no messages.
This commit is contained in:
@ -5469,10 +5469,27 @@ RSpec.describe TopicsController do
|
||||
end
|
||||
|
||||
context "for anons" do
|
||||
it "returns a 404" do
|
||||
it "returns a 404 if there is no cached summary" do
|
||||
get "/t/#{topic.id}/strategy-summary.json"
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "returns a cached summary" do
|
||||
section =
|
||||
SummarySection.create!(
|
||||
target: topic,
|
||||
summarized_text: "test",
|
||||
algorithm: "test",
|
||||
original_content_sha: "test",
|
||||
)
|
||||
|
||||
get "/t/#{topic.id}/strategy-summary.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
summary = response.parsed_body
|
||||
expect(summary["summary"]).to eq(section.summarized_text)
|
||||
end
|
||||
end
|
||||
|
||||
@ -5498,15 +5515,32 @@ RSpec.describe TopicsController do
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user is not a member of an allowlited group" do
|
||||
context "when the user is not a member of an allowlisted group" do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
it "return a 404" do
|
||||
it "return a 404 if there is no cached summary" do
|
||||
get "/t/#{topic.id}/strategy-summary.json"
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "returns a cached summary" do
|
||||
section =
|
||||
SummarySection.create!(
|
||||
target: topic,
|
||||
summarized_text: "test",
|
||||
algorithm: "test",
|
||||
original_content_sha: "test",
|
||||
)
|
||||
|
||||
get "/t/#{topic.id}/strategy-summary.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
summary = response.parsed_body
|
||||
expect(summary["summary"]).to eq(section.summarized_text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user