Module: RubyLLM::Providers::Gemini::Images
- Included in:
- RubyLLM::Providers::Gemini
- Defined in:
- lib/ruby_llm/providers/gemini/images.rb
Overview
Image generation methods for the Gemini API implementation
Instance Method Summary collapse
- #images_url ⇒ Object
- #parse_image_response(response, model:) ⇒ Object
- #render_image_payload(prompt, model:, size:) ⇒ Object
Instance Method Details
#images_url ⇒ Object
8 9 10 |
# File 'lib/ruby_llm/providers/gemini/images.rb', line 8 def images_url "models/#{@model}:predict" end |
#parse_image_response(response, model:) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_llm/providers/gemini/images.rb', line 27 def parse_image_response(response, model:) data = response.body image_data = data['predictions']&.first unless image_data&.key?('bytesBase64Encoded') raise Error, 'Unexpected response format from Gemini image generation API' end mime_type = image_data['mimeType'] || 'image/png' base64_data = image_data['bytesBase64Encoded'] Image.new( data: base64_data, mime_type: mime_type, model_id: model ) end |
#render_image_payload(prompt, model:, size:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_llm/providers/gemini/images.rb', line 12 def render_image_payload(prompt, model:, size:) RubyLLM.logger.debug "Ignoring size #{size}. Gemini does not support image size customization." @model = model { instances: [ { prompt: prompt } ], parameters: { sampleCount: 1 } } end |