Module: RubyLLM::Providers::Azure::Videos
- Included in:
- ChatCompletions, Responses
- Defined in:
- lib/ruby_llm/providers/azure/videos.rb
Overview
Sora video generation jobs on Azure OpenAI. The API lives under the resource's /openai/v1 base and is versioned 'preview' while Sora is in preview.
Constant Summary collapse
- API_VERSION =
'preview'
Instance Method Summary collapse
- #download_video(job) ⇒ Object
- #parse_video_job(response, model:) ⇒ Object
-
#parse_video_job_status(response, job:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
#render_video_payload(prompt, model:, with: [], provider_options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- #video_job_url(job) ⇒ Object
- #video_url ⇒ Object
Instance Method Details
#download_video(job) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ruby_llm/providers/azure/videos.rb', line 41 def download_video(job) generation_id = job.raw.dig('generations', 0, 'id') raise Error, 'Azure video job has no generations' unless generation_id response = @connection.get azure_video_url("video/generations/#{generation_id}/content/video") Video.new( data: response.body, mime_type: response.headers['content-type'] || 'video/mp4', model: job.raw['model'] || job.model, duration: job.raw['n_seconds'], raw: job.raw ) end |
#parse_video_job(response, model:) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ruby_llm/providers/azure/videos.rb', line 20 def parse_video_job(response, model:) id = response.body['id'] raise Error.new('Azure did not return a video generation job', response:) unless id VideoJob.new(id: id, protocol: self, model: model, raw: response.body) end |
#parse_video_job_status(response, job:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby_llm/providers/azure/videos.rb', line 31 def parse_video_job_status(response, job:) # rubocop:disable Lint/UnusedMethodArgument body = response.body case body['status'] when 'succeeded' then { status: :completed, raw: body } when 'failed', 'cancelled' { status: :failed, raw: body, error: body['failure_reason'] || body['status'] } else { status: :pending, raw: body } end end |
#render_video_payload(prompt, model:, with: [], provider_options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
16 17 18 |
# File 'lib/ruby_llm/providers/azure/videos.rb', line 16 def render_video_payload(prompt, model:, with: [], provider_options: {}) # rubocop:disable Lint/UnusedMethodArgument { model: model, prompt: prompt }.merge() end |
#video_job_url(job) ⇒ Object
27 28 29 |
# File 'lib/ruby_llm/providers/azure/videos.rb', line 27 def video_job_url(job) azure_video_url("video/generations/jobs/#{job.id}") end |
#video_url ⇒ Object
12 13 14 |
# File 'lib/ruby_llm/providers/azure/videos.rb', line 12 def video_url azure_video_url('video/generations/jobs') end |