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:
Roman Rizzi
2023-07-12 11:21:51 -03:00
committed by GitHub
parent 0b8fcb7c72
commit 61aeb2da90
27 changed files with 378 additions and 156 deletions

View File

@ -21,13 +21,24 @@ module Summarization
find_strategy(SiteSetting.summarization_strategy)
end
end
def can_request_summaries?(user)
user_group_ids = user.group_ids
def can_see_summary?(target, user)
return false if SiteSetting.summarization_strategy.blank?
SiteSetting.custom_summarization_allowed_groups_map.any? do |group_id|
user_group_ids.include?(group_id)
has_cached_summary = SummarySection.exists?(target: target, meta_section_id: nil)
return has_cached_summary if user.nil?
has_cached_summary || can_request_summary_for?(user)
end
def can_request_summary_for?(user)
return false unless user
user_group_ids = user.group_ids
SiteSetting.custom_summarization_allowed_groups_map.any? do |group_id|
user_group_ids.include?(group_id)
end
end
end