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_content_attachment(attachment) ⇒ Object
- .format_text(text) ⇒ Object
- .format_text_file(text_file) ⇒ Object
Class Method Details
.format_attachment(attachment) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 39 def () { inline_data: { mime_type: .mime_type, data: .encoded } } end |
.format_content(content) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 13 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 || parts << () end parts end |
.format_content_attachment(attachment) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 28 def () case .type when :text format_text_file() when :document, :unknown raise UnsupportedAttachmentError, .mime_type else () end end |
.format_text(text) ⇒ Object
54 55 56 57 58 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 54 def format_text(text) { text: text } end |
.format_text_file(text_file) ⇒ Object
48 49 50 51 52 |
# File 'lib/ruby_llm/providers/gemini/media.rb', line 48 def format_text_file(text_file) { text: text_file.for_llm } end |