Module: RubyLLM::Agents::ImageGenerator::Templates
- Defined in:
- lib/ruby_llm/agents/image/generator/templates.rb
Overview
Prompt template support for image generators
Allows defining reusable prompt templates that wrap user input with consistent styling, quality, or context instructions.
Constant Summary collapse
- PRESETS =
Common prompt templates for different use cases
{ # Photography styles product: "Professional product photography of {prompt}, " \ "white background, studio lighting, high resolution, commercial quality", portrait: "Professional portrait of {prompt}, " \ "soft lighting, shallow depth of field, 85mm lens, studio quality", landscape: "Stunning landscape photograph of {prompt}, " \ "golden hour lighting, dramatic sky, high dynamic range", # Artistic styles watercolor: "Watercolor painting of {prompt}, " \ "soft brushstrokes, muted colors, artistic, on textured paper", oil_painting: "Oil painting of {prompt}, " \ "rich colors, visible brushwork, classical style, museum quality", digital_art: "Digital art of {prompt}, " \ "vibrant colors, detailed, trending on artstation, 4k", anime: "Anime style illustration of {prompt}, " \ "detailed, Studio Ghibli inspired, beautiful lighting", # Technical styles isometric: "Isometric 3D render of {prompt}, " \ "clean lines, bright colors, game asset style", blueprint: "Technical blueprint of {prompt}, " \ "detailed engineering drawing, white lines on blue background", wireframe: "3D wireframe render of {prompt}, " \ "clean geometric lines, technical visualization", # UI/Design icon: "App icon design of {prompt}, " \ "flat design, bold colors, minimal, iOS style, high resolution", logo: "Minimalist logo design for {prompt}, " \ "clean lines, professional, vector style, brand identity", ui_mockup: "Modern UI mockup of {prompt}, " \ "clean design, shadows, glass morphism, Figma style" }.freeze
Class Method Summary collapse
-
.apply(template, **vars) ⇒ String
Apply a template to a prompt with variable substitution.
-
.apply_preset(name, prompt) ⇒ String
Apply a preset template to a prompt.
-
.preset(name) ⇒ String?
Get a preset template by name.
-
.preset_names ⇒ Array<Symbol>
List all available preset names.
Class Method Details
.apply(template, **vars) ⇒ String
Apply a template to a prompt with variable substitution
85 86 87 88 89 90 91 |
# File 'lib/ruby_llm/agents/image/generator/templates.rb', line 85 def apply(template, **vars) result = template.dup vars.each do |key, value| result.gsub!("{#{key}}", value.to_s) end result end |
.apply_preset(name, prompt) ⇒ String
Apply a preset template to a prompt
114 115 116 117 118 119 |
# File 'lib/ruby_llm/agents/image/generator/templates.rb', line 114 def apply_preset(name, prompt) template = preset(name) raise ArgumentError, "Unknown template preset: #{name}" unless template apply(template, prompt: prompt) end |
.preset(name) ⇒ String?
Get a preset template by name
97 98 99 |
# File 'lib/ruby_llm/agents/image/generator/templates.rb', line 97 def preset(name) PRESETS[name.to_sym] end |
.preset_names ⇒ Array<Symbol>
List all available preset names
104 105 106 |
# File 'lib/ruby_llm/agents/image/generator/templates.rb', line 104 def preset_names PRESETS.keys end |