Module: RubyLLM::Providers::GPUStack::Media
- Included in:
- ChatCompletions
- Defined in:
- lib/ruby_llm/providers/gpustack/media.rb
Overview
Handles formatting of media content for GPUStack. Images ride inline as base64 data URLs so the cluster never has to fetch remote sources.
Class Method Summary collapse
- .format_content(content, attachments = []) ⇒ Object
- .format_image(image) ⇒ Object
- .format_video(video) ⇒ Object
Class Method Details
.format_content(content, attachments = []) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_llm/providers/gpustack/media.rb', line 11 def format_content(content, = []) Protocols::ChatCompletions::Media.format_parts(content, ) do || case .type when :image format_image() when :audio Protocols::ChatCompletions::Media.format_audio() when :video format_video() when :text Protocols::ChatCompletions::Media.format_text_file() else raise UnsupportedAttachmentError, .mime_type end end end |
.format_image(image) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_llm/providers/gpustack/media.rb', line 28 def format_image(image) { type: 'image_url', image_url: { url: image.for_llm, detail: 'auto' } } end |
.format_video(video) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/ruby_llm/providers/gpustack/media.rb', line 38 def format_video(video) { type: 'video_url', video_url: { url: video.url? ? video.source.to_s : video.for_llm } } end |