Module: RubyLLM::Providers::Azure::Media
- Included in:
- RubyLLM::Providers::Azure
- Defined in:
- lib/ruby_llm/providers/azure/media.rb
Overview
Handles formatting of media content (images, audio) for Azure OpenAI-compatible APIs.
Class Method Summary collapse
-
.format_content(content) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity.
- .format_image(image) ⇒ Object
Class Method Details
.format_content(content) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_llm/providers/azure/media.rb', line 10 def format_content(content) # rubocop:disable Metrics/PerceivedComplexity return content.value if content.is_a?(RubyLLM::Content::Raw) return content.to_json if content.is_a?(Hash) || content.is_a?(Array) return content unless content.is_a?(Content) parts = [] parts << OpenAI::Media.format_text(content.text) if content.text content..each do || case .type when :image parts << format_image() when :audio parts << OpenAI::Media.format_audio() when :text parts << OpenAI::Media.format_text_file() else raise UnsupportedAttachmentError, .type end end parts end |
.format_image(image) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/ruby_llm/providers/azure/media.rb', line 34 def format_image(image) { type: 'image_url', image_url: { url: image.for_llm } } end |