Class: Cloudflare::AI::Binding
- Inherits:
-
Object
- Object
- Cloudflare::AI::Binding
- Defined in:
- lib/homura/runtime/ai.rb
Instance Attribute Summary collapse
-
#js ⇒ Object
readonly
Returns the value of attribute js.
Instance Method Summary collapse
- #available? ⇒ Boolean
-
#initialize(js) ⇒ Binding
constructor
A new instance of Binding.
- #run(model, inputs = nil, options: nil, **input_options) ⇒ Object
- #run_stream(model, inputs = nil, **input_options) ⇒ Object
Constructor Details
#initialize(js) ⇒ Binding
Returns a new instance of Binding.
43 44 45 |
# File 'lib/homura/runtime/ai.rb', line 43 def initialize(js) @js = js end |
Instance Attribute Details
#js ⇒ Object (readonly)
Returns the value of attribute js.
41 42 43 |
# File 'lib/homura/runtime/ai.rb', line 41 def js @js end |
Instance Method Details
#available? ⇒ Boolean
47 48 49 50 |
# File 'lib/homura/runtime/ai.rb', line 47 def available? js = @js !!`(#{js} !== null && #{js} !== undefined && #{js} !== Opal.nil)` end |
#run(model, inputs = nil, options: nil, **input_options) ⇒ Object
52 53 54 55 56 |
# File 'lib/homura/runtime/ai.rb', line 52 def run(model, inputs = nil, options: nil, **) payload = inputs || payload = payload.merge() if inputs.is_a?(Hash) && !.empty? Cloudflare::AI.run(model, payload, binding: @js, options: ) end |
#run_stream(model, inputs = nil, **input_options) ⇒ Object
58 59 60 61 62 |
# File 'lib/homura/runtime/ai.rb', line 58 def run_stream(model, inputs = nil, **) payload = inputs || payload = payload.merge() if inputs.is_a?(Hash) && !.empty? run(model, payload.merge(stream: true)) end |