0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/plugins/discourse-ai/lib/configuration/image_caption_enabled_validator.rb
Natalie Tay 86680f6b0d
FEATURE: Dedicated image caption AI feature and agent validations (#41729)
Follow up to https://github.com/discourse/discourse/pull/41586


1. **Bulk of the PR diff** -- there's a mix of usages for "description"
and "caption", we'll stick to V1 terminology and keep "AI caption"
instead of bringing in "description".

2. Move image caption out of AI helper, into its own dedicated "AI
Feature" for consolidated settings

3. Update default values for the existing image caption agent 
- vision_enabled was default off, now on
- update description

4. Validations and problem checks
- via Site Setting validation - agent / llm
  - when enabling the feature
  - or when selecting invalid agent

- inform admin when they've enabled the setting but the agent is
misconfigured via ProblemCheck
2026-07-16 11:29:39 +08:00

27 lines
572 B
Ruby
Vendored

# frozen_string_literal: true
module DiscourseAi
module Configuration
class ImageCaptionEnabledValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(val)
return true if val == false || val == "f" || val == "false"
agent_validator.valid_agent_value?(SiteSetting.ai_image_caption_agent)
end
def error_message
agent_validator.error_message
end
private
def agent_validator
@agent_validator ||= ImageCaptionAgentValidator.new(@opts)
end
end
end
end