Module: RubyLLM::Protocols::Gemini::Images
- Defined in:
- lib/ruby_llm/protocols/gemini/images.rb
Overview
Image generation methods for the Gemini API implementation
Constant Summary collapse
- IMAGE_SIZES =
%w[512 512P 512PX 1K 2K 4K].freeze
- ASPECT_RATIO =
/\A\d+:\d+\z/- PIXEL_DIMENSIONS =
/\A(\d+)\s*[x×]\s*(\d+)\z/i
Instance Method Summary collapse
-
#images_url(with: nil, mask: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- #parse_image_response(response, model:) ⇒ Object
- #parse_image_responses(response, model:) ⇒ Object
-
#render_image_payload(prompt, model:, size:, count: nil, with: nil, mask: nil, provider_options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
Instance Method Details
#images_url(with: nil, mask: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
12 13 14 15 16 |
# File 'lib/ruby_llm/protocols/gemini/images.rb', line 12 def images_url(with: nil, mask: nil) # rubocop:disable Lint/UnusedMethodArgument id = model_id(@model) "models/#{id}:#{image_endpoint_action(id)}" end |
#parse_image_response(response, model:) ⇒ Object
29 30 31 |
# File 'lib/ruby_llm/protocols/gemini/images.rb', line 29 def parse_image_response(response, model:) parse_image_responses(response, model:).first end |
#parse_image_responses(response, model:) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/ruby_llm/protocols/gemini/images.rb', line 33 def parse_image_responses(response, model:) data = response.body return parse_gemini_image_responses(data, model:) if gemini_image_model?(model) parse_imagen_responses(data, model:) end |
#render_image_payload(prompt, model:, size:, count: nil, with: nil, mask: nil, provider_options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby_llm/protocols/gemini/images.rb', line 18 def render_image_payload(prompt, model:, size:, count: nil, with: nil, mask: nil, provider_options: {}) # rubocop:disable Lint/UnusedMethodArgument @model = model payload = if gemini_image_model?(model) render_gemini_image_payload(prompt, with:, count:, size:) else render_imagen_payload(prompt, count:, size:) end Support::Utils.deep_merge(payload, ) end |