Class: PromptBuilder::Content::InputVideo

Inherits:
Base
  • Object
show all
Defined in:
lib/prompt_builder/content/input_video.rb

Overview

Represents video input content in a message.

Constant Summary

Constants inherited from Base

Base::TYPES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url: nil, **extra) ⇒ InputVideo

Create a new InputVideo content object.

Parameters:

  • url (String, nil) (defaults to: nil)

    the video URL

  • extra (Hash)

    provider-specific extra keyword arguments



27
28
29
30
# File 'lib/prompt_builder/content/input_video.rb', line 27

def initialize(url: nil, **extra)
  @url = url&.to_s
  @extra = extra.transform_keys(&:to_s)
end

Instance Attribute Details

#extraHash? (readonly)

Returns provider-specific extra data.

Returns:

  • (Hash, nil)

    provider-specific extra data



11
12
13
# File 'lib/prompt_builder/content/input_video.rb', line 11

def extra
  @extra
end

#urlString? (readonly)

Returns the video URL.

Returns:

  • (String, nil)

    the video URL



8
9
10
# File 'lib/prompt_builder/content/input_video.rb', line 8

def url
  @url
end

Class Method Details

.from_h(hash) ⇒ InputVideo

Deserialize an InputVideo from a Hash.

Parameters:

  • hash (Hash)

    a Hash with string keys

Returns:



18
19
20
# File 'lib/prompt_builder/content/input_video.rb', line 18

def from_h(hash)
  new(url: hash["url"], **hash.except("type", "url").transform_keys(&:to_sym))
end

Instance Method Details

#to_hHash

Serialize to a Hash with string keys. Nil values are omitted.

Returns:

  • (Hash)


35
36
37
38
39
40
# File 'lib/prompt_builder/content/input_video.rb', line 35

def to_h
  h = {"type" => "input_video"}
  h["url"] = @url if @url
  h = PromptBuilder.jsonify(@extra).merge(h) unless @extra.empty?
  h
end