Class: PromptBuilder::Content::InputVideo
- Defined in:
- lib/prompt_builder/content/input_video.rb
Overview
Represents video input content in a message.
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#extra ⇒ Hash?
readonly
Provider-specific extra data.
-
#url ⇒ String?
readonly
The video URL.
Class Method Summary collapse
-
.from_h(hash) ⇒ InputVideo
Deserialize an InputVideo from a Hash.
Instance Method Summary collapse
-
#initialize(url: nil, **extra) ⇒ InputVideo
constructor
Create a new InputVideo content object.
-
#to_h ⇒ Hash
Serialize to a Hash with string keys.
Constructor Details
#initialize(url: nil, **extra) ⇒ InputVideo
Create a new InputVideo content object.
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
#extra ⇒ Hash? (readonly)
Returns provider-specific extra data.
11 12 13 |
# File 'lib/prompt_builder/content/input_video.rb', line 11 def extra @extra end |
#url ⇒ String? (readonly)
Returns 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.
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_h ⇒ Hash
Serialize to a Hash with string keys. Nil values are omitted.
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 |