Module: RubyLLM::Providers::Gemini::Media
- Included in:
- RubyLLM::Providers::Gemini
- Defined in:
- lib/ruby_llm/providers/gemini/media.rb
Overview
Media handling methods for the Gemini API integration
Class Method Summary collapse
- .format_attachment(attachment) ⇒ Object
- .format_content(content) ⇒ Object
- .format_text(text) ⇒ Object
- .format_text_file(text_file) ⇒ Object
Class Method Details
.format_attachment(attachment) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 32 def () { inline_data: { mime_type: .mime_type, data: .encoded } } end |
.format_content(content) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 10 def format_content(content) return content.value if content.is_a?(RubyLLM::Content::Raw) return [format_text(content.to_json)] if content.is_a?(Hash) || content.is_a?(Array) return [format_text(content)] unless content.is_a?(Content) parts = [] parts << format_text(content.text) if content.text content..each do || case .type when :text parts << format_text_file() when :unknown raise UnsupportedAttachmentError, .mime_type else parts << () end end parts end |
.format_text(text) ⇒ Object
47 48 49 50 51 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 47 def format_text(text) { text: text } end |
.format_text_file(text_file) ⇒ Object
41 42 43 44 45 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 41 def format_text_file(text_file) { text: text_file.for_llm } end |