Module: LLM::Gemini::Response::Image
- Defined in:
- lib/llm/providers/gemini/response/image.rb
Instance Method Summary collapse
-
#images ⇒ Array<StringIO>
-
#urls ⇒ Array<String>
Returns one or more image URLs, or an empty array.
-
#candidates ⇒ Array<Hash>
Returns one or more candidates, or an empty array.
Instance Method Details
#images ⇒ Array<StringIO>
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/llm/providers/gemini/response/image.rb', line 7 def images candidates.flat_map do |candidate| parts = candidate&.dig(:content, :parts) || [] parts.filter_map do data = _1.dig(:inlineData, :data) next unless data StringIO.new(data.unpack1("m0")) end end end |
#urls ⇒ Array<String>
Note:
Gemini’s image generation API does not return URLs, so this method will always return an empty array.
Returns one or more image URLs, or an empty array
24 |
# File 'lib/llm/providers/gemini/response/image.rb', line 24 def urls = [] |
#candidates ⇒ Array<Hash>
Returns one or more candidates, or an empty array
29 |
# File 'lib/llm/providers/gemini/response/image.rb', line 29 def candidates = body.candidates || [] |