Class: RubyLlmAgents::ImageEditorGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- RubyLlmAgents::ImageEditorGenerator
- Defined in:
- lib/generators/ruby_llm_agents/image_editor_generator.rb
Overview
ImageEditor generator for creating new image editors
Usage:
rails generate ruby_llm_agents:image_editor Product
rails generate ruby_llm_agents:image_editor Background --model gpt-image-1 --size 1024x1024
rails generate ruby_llm_agents:image_editor Photo --content_policy strict
This will create:
- app/agents/images/product_editor.rb
Instance Method Summary collapse
Instance Method Details
#create_image_editor_file ⇒ Object
47 48 49 50 |
# File 'lib/generators/ruby_llm_agents/image_editor_generator.rb', line 47 def create_image_editor_file editor_path = name.underscore template "image_editor.rb.tt", "app/agents/images/#{editor_path}_editor.rb" end |
#ensure_base_class_and_skill_file ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/ruby_llm_agents/image_editor_generator.rb', line 28 def ensure_base_class_and_skill_file images_dir = "app/agents/images" # Create directory if needed empty_directory images_dir # Create base class if it doesn't exist base_class_path = "#{images_dir}/application_image_editor.rb" unless File.exist?(File.join(destination_root, base_class_path)) template "application_image_editor.rb.tt", base_class_path end # Create skill file if it doesn't exist skill_file_path = "#{images_dir}/IMAGE_EDITORS.md" unless File.exist?(File.join(destination_root, skill_file_path)) template "skills/IMAGE_EDITORS.md.tt", skill_file_path end end |
#show_usage ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/generators/ruby_llm_agents/image_editor_generator.rb', line 52 def show_usage editor_class_name = name.split("/").map(&:camelize).join("::") full_class_name = "Images::#{editor_class_name}Editor" say "" say "Image editor #{full_class_name} created!", :green say "" say "Usage:" say " # Edit an image with a mask" say " result = #{full_class_name}.call(" say " image: 'photo.png'," say " mask: 'mask.png'," say " prompt: 'Replace the background with a beach scene'" say " )" say " result.url # => 'https://...'" say "" say " # Generate multiple edit variations" say " result = #{full_class_name}.call(" say " image: 'photo.png'," say " mask: 'mask.png'," say " prompt: 'Add a sunset'," say " count: 3" say " )" say " result.urls # => ['https://...', ...]" say "" end |