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 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, infrared heating 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.



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

def initialize(metadata: nil)
  @metadata = 
end

Class Method Details

.render(metadata: nil) ⇒ Object



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

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

Instance Method Details

#system_promptObject



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

def system_prompt
  SYSTEM_CONTENT
end

#to_sObject



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

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