mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Pass the user who requested the summary to the strategy. (#24489)
This change allows the `discourse-ai` plugin to log the user who requested the summary in the `AiApiAuditLog`.
This commit is contained in:
parent
18cbb37e23
commit
75e2c6b506
@ -35,7 +35,7 @@ class TopicSummarization
|
|||||||
content[:contents] << { poster: username, id: pn, text: raw }
|
content[:contents] << { poster: username, id: pn, text: raw }
|
||||||
end
|
end
|
||||||
|
|
||||||
summarization_result = strategy.summarize(content, &on_partial_blk)
|
summarization_result = strategy.summarize(content, user, &on_partial_blk)
|
||||||
|
|
||||||
cache_summary(summarization_result, targets_data.map(&:first), topic)
|
cache_summary(summarization_result, targets_data.map(&:first), topic)
|
||||||
end
|
end
|
||||||
|
@ -75,6 +75,8 @@ module Summarization
|
|||||||
# @param &on_partial_blk { Block - Optional } - If the strategy supports it, the passed block
|
# @param &on_partial_blk { Block - Optional } - If the strategy supports it, the passed block
|
||||||
# will get called with partial summarized text as its generated.
|
# will get called with partial summarized text as its generated.
|
||||||
#
|
#
|
||||||
|
# @param current_user { User } - User requesting the summary.
|
||||||
|
#
|
||||||
# @returns { Hash } - The summarized content, plus chunks if the content couldn't be summarized in one pass. Example:
|
# @returns { Hash } - The summarized content, plus chunks if the content couldn't be summarized in one pass. Example:
|
||||||
# {
|
# {
|
||||||
# summary: "This is the final summary",
|
# summary: "This is the final summary",
|
||||||
@ -83,7 +85,7 @@ module Summarization
|
|||||||
# { ids: [post_1.post_number, post_2.post_number], summary: "this is the second chunk" },
|
# { ids: [post_1.post_number, post_2.post_number], summary: "this is the second chunk" },
|
||||||
# ],
|
# ],
|
||||||
# }
|
# }
|
||||||
def summarize(content)
|
def summarize(content, current_user)
|
||||||
raise NotImplemented
|
raise NotImplemented
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class Chat::Api::SummariesController < Chat::ApiController
|
|||||||
if content[:contents].empty?
|
if content[:contents].empty?
|
||||||
I18n.t("chat.summaries.no_targets")
|
I18n.t("chat.summaries.no_targets")
|
||||||
else
|
else
|
||||||
strategy.summarize(content).dig(:summary)
|
strategy.summarize(content, current_user).dig(:summary)
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: { summary: summarized_text }
|
render json: { summary: summarized_text }
|
||||||
|
@ -21,7 +21,7 @@ class DummyCustomSummarization < Summarization::Base
|
|||||||
"dummy"
|
"dummy"
|
||||||
end
|
end
|
||||||
|
|
||||||
def summarize(_content)
|
def summarize(_content, _user)
|
||||||
@summarization_result.tap { |result| yield(result[:summary]) if block_given? }
|
@summarization_result.tap { |result| yield(result[:summary]) if block_given? }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user