FEATURE: safeguard to avoid over triage (#626)
- a post can be triaged a maximum of twice a minute - system can run a total of 60 triages a minute Low defaults were picked to safeguard against any possible loops This can be amended if required via hidden site settings.
This commit is contained in:
parent
d64cff7692
commit
255139056d
|
@ -358,3 +358,9 @@ discourse_ai:
|
|||
ai_bot_github_access_token:
|
||||
default: ""
|
||||
secret: true
|
||||
ai_automation_max_triage_per_minute:
|
||||
default: 60
|
||||
hidden: true
|
||||
ai_automation_max_triage_per_post_per_minute:
|
||||
default: 2
|
||||
hidden: true
|
||||
|
|
|
@ -53,6 +53,20 @@ if defined?(DiscourseAutomation)
|
|||
flag_post = fields.dig("flag_post", "value")
|
||||
|
||||
begin
|
||||
RateLimiter.new(
|
||||
Discourse.system_user,
|
||||
"llm_triage_#{post.id}",
|
||||
SiteSetting.ai_automation_max_triage_per_post_per_minute,
|
||||
1.minute,
|
||||
).performed!
|
||||
|
||||
RateLimiter.new(
|
||||
Discourse.system_user,
|
||||
"llm_triage",
|
||||
SiteSetting.ai_automation_max_triage_per_minute,
|
||||
1.minute,
|
||||
).performed!
|
||||
|
||||
DiscourseAi::Automation::LlmTriage.handle(
|
||||
post: post,
|
||||
model: model,
|
||||
|
@ -66,7 +80,7 @@ if defined?(DiscourseAutomation)
|
|||
flag_post: flag_post,
|
||||
)
|
||||
rescue => e
|
||||
Discourse.warn_exception(e, message: "llm_triage: failed to run inference")
|
||||
Discourse.warn_exception(e, message: "llm_triage: skipped triage on post #{post.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue