DEV: Remove redundant `_changed`
This commit is contained in:
parent
231782c91e
commit
0cae647e59
|
@ -181,19 +181,7 @@ module DiscourseAi
|
||||||
def log_ai_embedding_update(embedding_def, initial_attributes)
|
def log_ai_embedding_update(embedding_def, initial_attributes)
|
||||||
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
||||||
entity_details = { embedding_id: embedding_def.id, subject: embedding_def.display_name }
|
entity_details = { embedding_id: embedding_def.id, subject: embedding_def.display_name }
|
||||||
|
|
||||||
# Add flags for specific field changes
|
|
||||||
if initial_attributes["provider"] != embedding_def.provider
|
|
||||||
entity_details[:provider_changed] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add a list of changed fields
|
|
||||||
changed_fields = []
|
|
||||||
embedding_def.previous_changes.each_key do |field|
|
|
||||||
changed_fields << field
|
|
||||||
end
|
|
||||||
entity_details[:changed_fields] = changed_fields.join(", ") if changed_fields.any?
|
|
||||||
|
|
||||||
logger.log_update(
|
logger.log_update(
|
||||||
"embedding",
|
"embedding",
|
||||||
embedding_def,
|
embedding_def,
|
||||||
|
|
|
@ -258,13 +258,6 @@ module DiscourseAi
|
||||||
def log_llm_model_update(llm_model, initial_attributes, initial_quotas)
|
def log_llm_model_update(llm_model, initial_attributes, initial_quotas)
|
||||||
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
||||||
entity_details = { model_id: llm_model.id, subject: llm_model.display_name }
|
entity_details = { model_id: llm_model.id, subject: llm_model.display_name }
|
||||||
|
|
||||||
# Track specific field changes
|
|
||||||
%w[name display_name provider api_key enabled_chat_bot vision_enabled].each do |field|
|
|
||||||
if initial_attributes[field].to_s != llm_model.read_attribute(field).to_s
|
|
||||||
entity_details["#{field}_changed"] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Track quota changes separately as they're a special case
|
# Track quota changes separately as they're a special case
|
||||||
current_quotas = llm_model.llm_quotas.reload.map(&:attributes)
|
current_quotas = llm_model.llm_quotas.reload.map(&:attributes)
|
||||||
|
|
|
@ -345,18 +345,6 @@ module DiscourseAi
|
||||||
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
||||||
entity_details = { persona_id: ai_persona.id, subject: ai_persona.name }
|
entity_details = { persona_id: ai_persona.id, subject: ai_persona.name }
|
||||||
entity_details[:tools_count] = ai_persona.tools.size if ai_persona.tools.present?
|
entity_details[:tools_count] = ai_persona.tools.size if ai_persona.tools.present?
|
||||||
|
|
||||||
# Check for name changes
|
|
||||||
if initial_attributes["name"] != ai_persona.name
|
|
||||||
entity_details[:name_changed] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add flags for other important changes
|
|
||||||
%w[system_prompt description default_llm_id tools].each do |field|
|
|
||||||
if initial_attributes[field].to_s != ai_persona.public_send(field).to_s
|
|
||||||
entity_details["#{field}_changed"] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
logger.log_update(
|
logger.log_update(
|
||||||
"persona",
|
"persona",
|
||||||
|
|
|
@ -129,18 +129,15 @@ module DiscourseAi
|
||||||
LlmModel.find_by(id: params[:llm_model_id])&.display_name || params[:llm_model_id]
|
LlmModel.find_by(id: params[:llm_model_id])&.display_name || params[:llm_model_id]
|
||||||
|
|
||||||
changes_to_log[:llm_model_id] = "#{old_model_name} → #{new_model_name}"
|
changes_to_log[:llm_model_id] = "#{old_model_name} → #{new_model_name}"
|
||||||
changes_to_log[:llm_model_changed] = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if params.key?(:custom_instructions) &&
|
if params.key?(:custom_instructions) &&
|
||||||
initial_custom_instructions != params[:custom_instructions]
|
initial_custom_instructions != params[:custom_instructions]
|
||||||
changes_to_log[:custom_instructions] = params[:custom_instructions]
|
changes_to_log[:custom_instructions] = params[:custom_instructions]
|
||||||
changes_to_log[:custom_instructions_changed] = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if changes_to_log.present?
|
if changes_to_log.present?
|
||||||
# Add a subject for the history record
|
changes_to_log[:subject] = I18n.t("discourse_ai.spam_detection.logging_subject")
|
||||||
changes_to_log[:subject] = "AI Spam Settings"
|
|
||||||
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
||||||
logger.log_custom("update_ai_spam_settings", changes_to_log)
|
logger.log_custom("update_ai_spam_settings", changes_to_log)
|
||||||
end
|
end
|
||||||
|
|
|
@ -148,12 +148,7 @@ module DiscourseAi
|
||||||
def log_ai_tool_update(ai_tool, initial_attributes)
|
def log_ai_tool_update(ai_tool, initial_attributes)
|
||||||
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
logger = DiscourseAi::Utils::AiStaffActionLogger.new(current_user)
|
||||||
entity_details = { tool_id: ai_tool.id, subject: ai_tool.name }
|
entity_details = { tool_id: ai_tool.id, subject: ai_tool.name }
|
||||||
|
|
||||||
# Add flags for specific field changes
|
|
||||||
if initial_attributes["name"] != ai_tool.name
|
|
||||||
entity_details[:name_changed] = true
|
|
||||||
end
|
|
||||||
|
|
||||||
logger.log_update(
|
logger.log_update(
|
||||||
"tool",
|
"tool",
|
||||||
ai_tool,
|
ai_tool,
|
||||||
|
|
|
@ -284,6 +284,7 @@ en:
|
||||||
unexpected: "An unexpected error occured"
|
unexpected: "An unexpected error occured"
|
||||||
bot_user_update_failed: "Failed to update the spam scanning bot user"
|
bot_user_update_failed: "Failed to update the spam scanning bot user"
|
||||||
configuration_missing: "The AI spam detection configuration is missing. Add configuration in the 'Admin > Plugins > Discourse AI > Spam' before enabling."
|
configuration_missing: "The AI spam detection configuration is missing. Add configuration in the 'Admin > Plugins > Discourse AI > Spam' before enabling."
|
||||||
|
logging_subject: "Spam detection"
|
||||||
|
|
||||||
ai_bot:
|
ai_bot:
|
||||||
reply_error: "Sorry, it looks like our system encountered an unexpected issue while trying to reply.\n\n[details='Error details']\n%{details}\n[/details]"
|
reply_error: "Sorry, it looks like our system encountered an unexpected issue while trying to reply.\n\n[details='Error details']\n%{details}\n[/details]"
|
||||||
|
|
Loading…
Reference in New Issue