Class: Clacky::Media::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/clacky/media/base.rb

Overview

Abstract base for media (image / video / audio) generation providers.

Subclasses implement #generate_image (and later #generate_video, #generate_audio). The base class supplies the uniform success/error response shape and the on-disk persistence helper, mirroring the design used by Hermes’ image_gen_provider so the surface stays learnable across modalities.

Direct Known Subclasses

DashScope, Gemini, OpenAICompat

Instance Method Summary collapse

Constructor Details

#initialize(model_entry) ⇒ Base

Returns a new instance of Base.

Parameters:

  • model_entry (Hash)

    one entry from AgentConfig#models — must include “model”, “base_url”, “api_key” keys.



20
21
22
23
24
25
# File 'lib/clacky/media/base.rb', line 20

def initialize(model_entry)
  @model_entry = model_entry
  @model       = model_entry["model"]
  @base_url    = model_entry["base_url"]
  @api_key     = model_entry["api_key"]
end

Instance Method Details

#generate_image(prompt:, aspect_ratio: "landscape", output_dir: nil, **_kwargs) ⇒ Hash

Returns either success_response(…) or error_response(…).

Returns:

  • (Hash)

    either success_response(…) or error_response(…)

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/clacky/media/base.rb', line 28

def generate_image(prompt:, aspect_ratio: "landscape", output_dir: nil, **_kwargs)
  raise NotImplementedError, "#{self.class.name} must implement #generate_image"
end

#generate_speech(input:, voice: nil, output_dir: nil, **_kwargs) ⇒ Hash

Returns either audio_success_response(…) or audio_error_response(…).

Returns:

  • (Hash)

    either audio_success_response(…) or audio_error_response(…)



45
46
47
48
49
50
51
52
# File 'lib/clacky/media/base.rb', line 45

def generate_speech(input:, voice: nil, output_dir: nil, **_kwargs)
  audio_error_response(
    error: "Speech synthesis is not supported by #{self.class.name.split("::").last}. Use the openclacky gateway with a TTS model such as or-tts-gemini-2-5-flash.",
    error_type: "not_implemented",
    provider: "",
    input: input
  )
end

#generate_video(prompt:, aspect_ratio: "landscape", duration_seconds: nil, output_dir: nil, **_kwargs) ⇒ Hash

Returns either video_success_response(…) or video_error_response(…).

Returns:

  • (Hash)

    either video_success_response(…) or video_error_response(…)



34
35
36
37
38
39
40
41
42
# File 'lib/clacky/media/base.rb', line 34

def generate_video(prompt:, aspect_ratio: "landscape", duration_seconds: nil, output_dir: nil, **_kwargs)
  video_error_response(
    error: "Video generation is not supported by #{self.class.name.split("::").last}. Use the openclacky gateway with a video model such as or-veo-3-1.",
    error_type: "not_implemented",
    provider: "",
    prompt: prompt,
    aspect_ratio: aspect_ratio
  )
end