2024-07-03 20:48:18 -04:00
|
|
|
# frozen_string_literal: true
|
2024-10-15 12:53:26 -04:00
|
|
|
|
2024-07-03 20:48:18 -04:00
|
|
|
module DiscourseAi
|
|
|
|
module Summarization
|
2024-10-15 12:53:26 -04:00
|
|
|
def self.topic_summary(topic)
|
2024-07-03 20:48:18 -04:00
|
|
|
if SiteSetting.ai_summarization_model.present? && SiteSetting.ai_summarization_enabled
|
2024-10-15 12:53:26 -04:00
|
|
|
DiscourseAi::Summarization::FoldContent.new(
|
|
|
|
DiscourseAi::Completions::Llm.proxy(SiteSetting.ai_summarization_model),
|
|
|
|
DiscourseAi::Summarization::Strategies::TopicSummary.new(topic),
|
|
|
|
)
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.topic_gist(topic)
|
|
|
|
if SiteSetting.ai_summarization_model.present? && SiteSetting.ai_summarization_enabled
|
|
|
|
DiscourseAi::Summarization::FoldContent.new(
|
|
|
|
DiscourseAi::Completions::Llm.proxy(SiteSetting.ai_summarization_model),
|
2024-10-18 17:01:39 -04:00
|
|
|
DiscourseAi::Summarization::Strategies::HotTopicGists.new(topic),
|
2024-10-15 12:53:26 -04:00
|
|
|
)
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.chat_channel_summary(channel, time_window_in_hours)
|
|
|
|
if SiteSetting.ai_summarization_model.present? && SiteSetting.ai_summarization_enabled
|
|
|
|
DiscourseAi::Summarization::FoldContent.new(
|
|
|
|
DiscourseAi::Completions::Llm.proxy(SiteSetting.ai_summarization_model),
|
|
|
|
DiscourseAi::Summarization::Strategies::ChatMessages.new(channel, time_window_in_hours),
|
|
|
|
persist_summaries: false,
|
|
|
|
)
|
2024-07-03 20:48:18 -04:00
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|