Class: ImageAnalysisPrompt

Inherits:
ApplicationPrompt show all
Defined in:
app/prompts/image_analysis_prompt.rb

Overview

Prompt for analyzing product images with GPT-4o Vision.
Used by ImageVisionWorker to generate semantic descriptions.

Examples:

prompt = ImageAnalysisPrompt.render(metadata: )

Constant Summary collapse

SYSTEM_CONTENT =
<<~SYSTEM
  You are an expert at analyzing product images for WarmlyYours, a radiant heating company.
  Your task is to describe images in detail for use in semantic search.

  Focus on:
  1. PRODUCTS: Identify specific products (TempZone Flex Rolls, TempZone Cables, Environ mats,
     snow melting mats, radiant panels, thermostats, etc.)
  2. INSTALLATION: Describe installation context (under tile, in cement, under laminate,
     outdoor pavers, driveways, etc.)
  3. ACTIONS: If people are present, describe what they're doing (measuring, laying product,
     connecting wires, etc.)
  4. ENVIRONMENT: Room type (bathroom, kitchen, basement), outdoor setting, or studio/product shot
  5. QUALITY: Note if it's a professional photo, installation guide, diagram, or user-submitted

  Be specific with product names and technical details. Keep descriptions concise but informative.
  Write in plain text, no markdown or bullet points.
SYSTEM

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationPrompt

#format_list, #truncate

Constructor Details

#initialize(metadata: nil) ⇒ ImageAnalysisPrompt

Returns a new instance of ImageAnalysisPrompt.



32
33
34
# File 'app/prompts/image_analysis_prompt.rb', line 32

def initialize(metadata: nil)
  @metadata = 
end

Class Method Details

.render(metadata: nil) ⇒ Object



28
29
30
# File 'app/prompts/image_analysis_prompt.rb', line 28

def self.render(metadata: nil)
  new(metadata: ).to_s
end

Instance Method Details

#system_promptObject



44
45
46
# File 'app/prompts/image_analysis_prompt.rb', line 44

def system_prompt
  SYSTEM_CONTENT
end

#to_sObject



36
37
38
39
40
41
42
# File 'app/prompts/image_analysis_prompt.rb', line 36

def to_s
  if @metadata.present?
    "#{SYSTEM_CONTENT}\n\nExisting metadata:\n#{@metadata}\n\nDescribe this image:"
  else
    "#{SYSTEM_CONTENT}\n\nDescribe this image:"
  end
end