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

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, attachments = [])
  Protocols::ChatCompletions::Media.format_parts(content, attachments) do |attachment|
    case attachment.type
    when :image
      format_image(attachment)
    when :audio
      Protocols::ChatCompletions::Media.format_audio(attachment)
    when :video
      format_video(attachment)
    when :text
      Protocols::ChatCompletions::Media.format_text_file(attachment)
    else
      raise UnsupportedAttachmentError, attachment.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