Module: RubyLLM::Agents::ImageGenerator::ActiveStorageSupport

Extended by:
ActiveSupport::Concern
Defined in:
lib/ruby_llm/agents/image/generator/active_storage_support.rb

Overview

ActiveStorage integration for image generators

Provides convenience methods for generating images and directly attaching them to ActiveStorage attachments.

Examples:

Attaching to a model

class Product < ApplicationRecord
  has_one_attached :hero_image
end

class ProductImageGenerator < RubyLLM::Agents::ImageGenerator
  include RubyLLM::Agents::ImageGenerator::ActiveStorageSupport

  model "gpt-image-1"
  size "1024x1024"
end

product = Product.find(1)
result = ProductImageGenerator.generate_and_attach(
  prompt: "Professional product photo of a red sneaker",
  record: product,
  attachment_name: :hero_image
)