discourse-ai/spec/models/ai_persona_spec.rb
Sam a4f419f54f
FEATURE: basic infrastructure for custom personas (#288)
- New AiPersona model which can store custom personas
- Persona are restricted via group security
- They can contain custom system messages
- They can support a list of commands optionally

To avoid expensive DB calls in the serializer a Multisite friendly Hash was introduced (which can be expired on transaction commit)
2023-11-10 11:39:49 +11:00

20 lines
554 B
Ruby

# frozen_string_literal: true
RSpec.describe AiPersona do
it "does not leak caches between sites" do
AiPersona.create!(
name: "pun_bot",
description: "you write puns",
system_prompt: "you are pun bot",
commands: ["ImageCommand"],
allowed_group_ids: [Group::AUTO_GROUPS[:trust_level_0]],
)
AiPersona.all_personas
expect(AiPersona.persona_cache[:value].length).to eq(1)
RailsMultisite::ConnectionManagement.stubs(:current_db) { "abc" }
expect(AiPersona.persona_cache[:value]).to eq(nil)
end
end