Class: RubyLlmAgents::ImagePipelineGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- RubyLlmAgents::ImagePipelineGenerator
- Defined in:
- lib/generators/ruby_llm_agents/image_pipeline_generator.rb
Overview
ImagePipeline generator for creating new image pipelines
Usage:
rails generate ruby_llm_agents:image_pipeline Product
rails generate ruby_llm_agents:image_pipeline Ecommerce --steps generate,upscale,remove_background
rails generate ruby_llm_agents:image_pipeline Content --steps generate,analyze
This will create:
- app/agents/images/product_pipeline.rb
Instance Method Summary collapse
- #create_image_pipeline_file ⇒ Object
- #create_step_classes ⇒ Object
- #ensure_base_class_and_skill_file ⇒ Object
- #show_usage ⇒ Object
Instance Method Details
#create_image_pipeline_file ⇒ Object
45 46 47 48 |
# File 'lib/generators/ruby_llm_agents/image_pipeline_generator.rb', line 45 def create_image_pipeline_file pipeline_path = name.underscore template "image_pipeline.rb.tt", "app/agents/images/#{pipeline_path}_pipeline.rb" end |
#create_step_classes ⇒ Object
50 51 52 53 54 55 |
# File 'lib/generators/ruby_llm_agents/image_pipeline_generator.rb', line 50 def create_step_classes # Create stub classes for referenced steps if they don't exist parsed_steps.each do |step| create_step_stub(step) if should_create_stub?(step) end end |
#ensure_base_class_and_skill_file ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/ruby_llm_agents/image_pipeline_generator.rb', line 26 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_pipeline.rb" unless File.exist?(File.join(destination_root, base_class_path)) template "application_image_pipeline.rb.tt", base_class_path end # Create skill file if it doesn't exist skill_file_path = "#{images_dir}/IMAGE_PIPELINES.md" unless File.exist?(File.join(destination_root, skill_file_path)) template "skills/IMAGE_PIPELINES.md.tt", skill_file_path end end |
#show_usage ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/generators/ruby_llm_agents/image_pipeline_generator.rb', line 57 def show_usage pipeline_class_name = name.split("/").map(&:camelize).join("::") full_class_name = "Images::#{pipeline_class_name}Pipeline" say "" say "Image pipeline #{full_class_name} created!", :green say "" say "Usage:" say " # Run the pipeline" say " result = #{full_class_name}.call(prompt: 'Product photo')" say " result.final_image # => The processed image" say " result.total_cost # => Combined cost of all steps" say " result.step_count # => Number of steps executed" say "" say " # Access individual step results" say " result.step(:generate) # => ImageGenerationResult" say " result.step(:upscale) # => ImageUpscaleResult" say " result.analysis # => ImageAnalysisResult (if analyzer step)" say "" say " # Save the final image" say " result.save('output.png')" say "" say " # With tenant tracking" say " result = #{full_class_name}.call(" say " prompt: 'Product photo'," say " tenant: current_organization" say " )" say "" end |