FIX: avoid all bot feedback loops (#507)
We need to ensure that under no circumstances feedback loops between bots will emerge cause this can eat up a lot of tokens
This commit is contained in:
parent
9485f3110a
commit
b7a96e3bcb
|
@ -12,12 +12,10 @@ module DiscourseAi
|
||||||
REQUIRE_TITLE_UPDATE = "discourse-ai-title-update"
|
REQUIRE_TITLE_UPDATE = "discourse-ai-title-update"
|
||||||
|
|
||||||
def self.is_bot_user_id?(user_id)
|
def self.is_bot_user_id?(user_id)
|
||||||
bot_ids = DiscourseAi::AiBot::EntryPoint::BOT_USER_IDS
|
# this will catch everything and avoid any feedback loops
|
||||||
bot_ids.include?(user_id) ||
|
# we could get feedback loops between say discobot and ai-bot or third party plugins
|
||||||
begin
|
# and bots
|
||||||
mentionable_ids = AiPersona.mentionables.map { |mentionable| mentionable[:user_id] }
|
user_id.to_i <= 0
|
||||||
mentionable_ids.include?(user_id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.schedule_reply(post)
|
def self.schedule_reply(post)
|
||||||
|
|
|
@ -52,6 +52,15 @@ RSpec.describe DiscourseAi::AiBot::Playground do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "is_bot_user_id?" do
|
||||||
|
it "properly detects ALL bots as bot users" do
|
||||||
|
persona = Fabricate(:ai_persona, enabled: false)
|
||||||
|
persona.create_user!
|
||||||
|
|
||||||
|
expect(DiscourseAi::AiBot::Playground.is_bot_user_id?(persona.user_id)).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "persona with user support" do
|
describe "persona with user support" do
|
||||||
before do
|
before do
|
||||||
Jobs.run_immediately!
|
Jobs.run_immediately!
|
||||||
|
|
Loading…
Reference in New Issue