0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-05 11:15:10 +08:00
discourse/plugins/discourse-ai/lib/agents/image_captioner.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

33 lines
738 B
Ruby
Vendored

# frozen_string_literal: true
module DiscourseAi
module Agents
class ImageCaptioner < Agent
def self.default_enabled
false
end
def self.vision_enabled
true
end
def system_prompt
<<~PROMPT.strip
You are a bot specializing in image captioning.
Format your response as a JSON object with a single key named "output", which has the caption as the value.
Your output should be in the following format:
{"output": "xx"}
Where "xx" is replaced by the caption.
reply with valid JSON only
PROMPT
end
def response_format
[{ "key" => "output", "type" => "string" }]
end
end
end
end