mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +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:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user