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

@ -1264,6 +1264,17 @@ class Plugin::Instance
DiscoursePluginRegistry.register_bookmarkable(RegisteredBookmarkable.new(klass), self)
end
##
# Register an object that inherits from [Summarization::Base], which provides a way
# to summarize content. Staff can select which strategy to use
# through the `summarization_strategy` setting.
def register_summarization_strategy(strategy)
if !strategy.class.ancestors.include?(Summarization::Base)
raise ArgumentError.new("Not a valid summarization strategy")
end
DiscoursePluginRegistry.register_summarization_strategy(strategy, self)
end
protected
def self.js_path