FIX: system persona non English save, missing bot pms

- FIX: only update system attributes when updating system persona
- FIX: update participant count by hand so bot messages show in inbox
 

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
Sam 2024-03-04 09:56:59 +11:00 committed by GitHub
parent c02794cf2e
commit 77cf9e2cff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 1 deletions

View File

@ -20,6 +20,18 @@ const ATTRIBUTES = [
"max_context_posts",
];
const SYSTEM_ATTRIBUTES = [
"allowed_group_ids",
"enabled",
"system",
"priority",
"user_id",
"mentionable",
"default_llm",
"user",
"max_context_posts",
];
class CommandOption {
@tracked value = null;
}
@ -97,7 +109,9 @@ export default class AiPersona extends RestModel {
}
updateProperties() {
let attrs = this.getProperties(ATTRIBUTES);
let attrs = this.system
? this.getProperties(SYSTEM_ATTRIBUTES)
: this.getProperties(ATTRIBUTES);
attrs.id = this.id;
this.populateCommandOptions(attrs);
return attrs;

View File

@ -273,6 +273,12 @@ module DiscourseAi
reply_post.post_custom_prompt.update!(custom_prompt: prompt)
end
# since we are skipping validations and jobs we
# may need to fix participant count
if reply_post.topic.private_message? && reply_post.topic.participant_count < 2
reply_post.topic.update!(participant_count: 2)
end
reply_post
ensure
publish_final_update(reply_post) if stream_reply

View File

@ -135,6 +135,8 @@ RSpec.describe DiscourseAi::AiBot::Playground do
last_post.topic.reload
expect(last_post.topic.allowed_users.pluck(:user_id)).to include(persona.user_id)
expect(last_post.topic.participant_count).to eq(2)
end
it "picks the correct llm for persona in PMs" do