Class: Clacky::Media::Generator
- Inherits:
-
Object
- Object
- Clacky::Media::Generator
- Defined in:
- lib/clacky/media/generator.rb
Overview
Top-level dispatcher: takes an AgentConfig and a request, picks the right provider class based on the configured image model’s base_url, and delegates.
Adding a new modality (video / audio) means:
1. add a generate_<modality> method here that resolves the correct
type=<modality> entry and class
2. add a provider class under lib/clacky/media/ implementing the call
Constant Summary collapse
- GOOGLE_NATIVE_HOSTS =
Hosts that speak the native Google AI Studio API instead of an OpenAI-compatible facade. Matched as a substring against the configured base_url so any regional / staging variant is caught.
[ "generativelanguage.googleapis.com", "aiplatform.googleapis.com" ].freeze
Instance Method Summary collapse
- #generate_image(prompt:, aspect_ratio: "landscape", output_dir: nil, **kwargs) ⇒ Object
-
#image_model_entry ⇒ Hash?
The type=image model entry, or nil if not configured.
-
#initialize(agent_config) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(agent_config) ⇒ Generator
Returns a new instance of Generator.
26 27 28 |
# File 'lib/clacky/media/generator.rb', line 26 def initialize(agent_config) @agent_config = agent_config end |
Instance Method Details
#generate_image(prompt:, aspect_ratio: "landscape", output_dir: nil, **kwargs) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/clacky/media/generator.rb', line 35 def generate_image(prompt:, aspect_ratio: "landscape", output_dir: nil, **kwargs) entry = image_model_entry if entry.nil? return { "success" => false, "image" => nil, "error" => "No image model configured. Add a model with type=image in settings.", "error_type" => "not_configured", "provider" => "", "model" => "", "prompt" => prompt } end provider = build_provider_for(entry) provider.generate_image( prompt: prompt, aspect_ratio: aspect_ratio, output_dir: output_dir, **kwargs ) end |
#image_model_entry ⇒ Hash?
Returns the type=image model entry, or nil if not configured.
31 32 33 |
# File 'lib/clacky/media/generator.rb', line 31 def image_model_entry @agent_config.find_model_by_type("image") end |