mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 01:53:39 +08:00
8938ecabc2
* 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'
20 lines
385 B
Ruby
20 lines
385 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SummarizationValidator
|
|
def initialize(opts = {})
|
|
@opts = opts
|
|
end
|
|
|
|
def valid_value?(val)
|
|
strategy = Summarization::Base.find_strategy(val)
|
|
|
|
return true unless strategy
|
|
|
|
strategy.correctly_configured?.tap { |is_valid| @strategy = strategy unless is_valid }
|
|
end
|
|
|
|
def error_message
|
|
@strategy.configuration_hint
|
|
end
|
|
end
|