Module: RubyLLM::Protocols::Gemini::Media
- Defined in:
- lib/ruby_llm/protocols/gemini/media.rb
Overview
Media handling methods for the Gemini API integration
Class Method Summary collapse
- .format_attachment(attachment) ⇒ Object
- .format_content(content, attachments = []) ⇒ Object
- .format_content_attachment(attachment) ⇒ Object
- .format_file_data(attachment) ⇒ Object
- .format_text(text) ⇒ Object
- .format_text_file(text_file) ⇒ Object
Class Method Details
.format_attachment(attachment) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby_llm/protocols/gemini/media.rb', line 35 def () return format_file_data() if .provider_file? { inline_data: { mime_type: .mime_type, data: .encoded } } end |
.format_content(content, attachments = []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_llm/protocols/gemini/media.rb', line 13 def format_content(content, = []) parts = [] parts << format_text(content) if content .each do || parts << () end parts end |
.format_content_attachment(attachment) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby_llm/protocols/gemini/media.rb', line 24 def () case .type when :text format_text_file() when :document, :unknown raise UnsupportedAttachmentError, .mime_type else () end end |
.format_file_data(attachment) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/ruby_llm/protocols/gemini/media.rb', line 46 def format_file_data() uri = .provider_file_uri || .provider_file_id { file_data: { mime_type: .mime_type, file_uri: uri } } end |
.format_text(text) ⇒ Object
62 63 64 65 66 |
# File 'lib/ruby_llm/protocols/gemini/media.rb', line 62 def format_text(text) { text: text } end |
.format_text_file(text_file) ⇒ Object
56 57 58 59 60 |
# File 'lib/ruby_llm/protocols/gemini/media.rb', line 56 def format_text_file(text_file) { text: text_file.for_llm } end |