FEATURE: Custom content summarization strategies. (#21813)

* FEATURE: Content custom summarization strategies.

This PR establishes a pattern for plugins to register alternative ways of summarizing content by extending a class that defines an interface.

Core controls which strategy we'll use and who has access to it through the `summarization_strategy` and `custom_summarization_allowed_groups`. It also defines the UI for summarizing topics.

Other plugins can access this summarization mechanism and implement their features, removing cross-plugin customizations, as it currently happens between chat and the discourse-ai plugin.

* Group membership validation and rate limiting

* Work with objects instead of classes

* Port summarization feature from discourse-ai to chat

* Rename available summaries to 'Top Replies' and 'Summary'
This commit is contained in:
Roman Rizzi
2023-06-13 14:21:46 -03:00
committed by GitHub
parent dcceb91000
commit 8938ecabc2
43 changed files with 649 additions and 58 deletions

View File

@@ -2054,10 +2054,13 @@ en:
other {# minutes}
}</b>.
enable: "Summarize This Topic"
enable: "Show top replies"
disable: "Show All Posts"
short_label: "Summarize"
short_title: "Show a summary of this topic: the most interesting posts as determined by the community"
strategy:
button_title: "Summarize this topic"
title: "Topic summary"
deleted_filter:
enabled_description: "This topic contains deleted posts, which have been hidden."

View File

@@ -1600,6 +1600,8 @@ en:
summary_percent_filter: "When a user clicks 'Summarize This Topic', show the top % of posts"
summary_max_results: "Maximum posts returned by 'Summarize This Topic'"
summary_timeline_button: "Show a 'Summarize' button in the timeline"
summarization_strategy: "Additional ways to summarize content registered by plugins"
custom_summarization_allowed_groups: "Groups allowed to summarize contents using the `summarization_strategy`."
enable_personal_messages: "DEPRECATED, use the 'personal message enabled groups' setting instead. Allow trust level 1 (configurable via min trust to send messages) users to create messages and reply to messages. Note that staff can always send messages no matter what."
personal_message_enabled_groups: "Allow users within these groups to create messages and reply to messages. Trust level groups include all trust levels above that number, for example choosing trust_level_1 also allows trust_level_2, 3, 4 users to send PMs. Note that staff can always send messages no matter what."

View File

@@ -1319,6 +1319,11 @@ Discourse::Application.routes.draw do
topic_id: /\d+/,
}
get "t/:topic_id/summary" => "topics#show", :constraints => { topic_id: /\d+/ }
get "t/:topic_id/strategy-summary" => "topics#summary",
:constraints => {
topic_id: /\d+/,
},
:format => :json
put "t/:slug/:topic_id" => "topics#update", :constraints => { topic_id: /\d+/ }
put "t/:slug/:topic_id/star" => "topics#star", :constraints => { topic_id: /\d+/ }
put "t/:topic_id/star" => "topics#star", :constraints => { topic_id: /\d+/ }

View File

@@ -2351,6 +2351,17 @@ uncategorized:
client: true
default: false
summarization_strategy:
client: true
default: ""
enum: "SummarizationStrategy"
validator: "SummarizationValidator"
custom_summarization_allowed_groups:
client: true
type: group_list
list_type: compact
default: "3|14" # 3: @staff, 14: @trust_level_4
automatic_topic_heat_values: true
# View heat thresholds