Module: RubyLLM::Protocols::GPUStack::Videos

Included in:
RubyLLM::Providers::GPUStack::ChatCompletions
Defined in:
lib/ruby_llm/protocols/gpustack/videos.rb

Overview

vLLM-Omni video jobs through GPUStack's model proxy.

Instance Method Summary collapse

Instance Method Details

#download_video(job) ⇒ Object



44
45
46
47
48
# File 'lib/ruby_llm/protocols/gpustack/videos.rb', line 44

def download_video(job)
  response = @connection.get("#{video_job_url(job)}/content")
  Video.new(data: response.body, mime_type: response.headers['content-type'] || job.raw['media_type'],
            model: job.model, raw: job.raw)
end

#parse_video_job(response, model:) ⇒ Object

Raises:



28
29
30
31
32
33
34
# File 'lib/ruby_llm/protocols/gpustack/videos.rb', line 28

def parse_video_job(response, model:)
  body = response.body
  id = body['id']
  raise Error.new('GPUStack did not return a video job id', response:) unless id

  VideoJob.new(id: id, protocol: self, model: body['model'] || model, **video_job_state(body))
end

#parse_video_job_status(response) ⇒ Object



40
41
42
# File 'lib/ruby_llm/protocols/gpustack/videos.rb', line 40

def parse_video_job_status(response, **)
  video_job_state(response.body)
end

#post_video(url, payload) ⇒ Object



22
23
24
25
26
# File 'lib/ruby_llm/protocols/gpustack/videos.rb', line 22

def post_video(url, payload)
  @connection.post(url, payload, idempotent: false) do |request|
    request.headers['Content-Type'] = 'multipart/form-data'
  end
end

#render_video_payload(prompt, model:, with: [], provider_options: {}) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
# File 'lib/ruby_llm/protocols/gpustack/videos.rb', line 12

def render_video_payload(prompt, model:, with: [], provider_options: {})
  raise ArgumentError, 'vLLM-Omni video generation requires a prompt' if prompt.nil?

  options = video_options(provider_options)
  payload = { model: model, prompt: prompt }.merge(video_references(with)).merge(options).compact
  payload.transform_values do |value|
    value.is_a?(Hash) || value.is_a?(Array) ? JSON.generate(value) : value
  end
end

#video_job_url(job) ⇒ Object



36
37
38
# File 'lib/ruby_llm/protocols/gpustack/videos.rb', line 36

def video_job_url(job)
  "#{video_url}/#{job.id}"
end

#video_urlObject



8
9
10
# File 'lib/ruby_llm/protocols/gpustack/videos.rb', line 8

def video_url
  "#{@provider.backend_api_base}/v1/videos"
end