Class: OxAiWorkers::ImageIterator
- Inherits:
-
Object
- Object
- OxAiWorkers::ImageIterator
- Defined in:
- lib/oxaiworkers/image_iterator.rb
Instance Attribute Summary collapse
-
#on_finish ⇒ Object
Returns the value of attribute on_finish.
-
#on_inner_monologue ⇒ Object
Returns the value of attribute on_inner_monologue.
-
#on_outer_voice ⇒ Object
Returns the value of attribute on_outer_voice.
-
#task ⇒ Object
Returns the value of attribute task.
-
#worker ⇒ Object
Returns the value of attribute worker.
Instance Method Summary collapse
- #add_task(task) ⇒ Object
- #cleanup ⇒ Object
- #execute ⇒ Object
-
#initialize(worker:, on_inner_monologue: nil, on_outer_voice: nil, on_finish: nil) ⇒ ImageIterator
constructor
A new instance of ImageIterator.
Constructor Details
#initialize(worker:, on_inner_monologue: nil, on_outer_voice: nil, on_finish: nil) ⇒ ImageIterator
Returns a new instance of ImageIterator.
7 8 9 10 11 12 |
# File 'lib/oxaiworkers/image_iterator.rb', line 7 def initialize(worker:, on_inner_monologue: nil, on_outer_voice: nil, on_finish: nil) @worker = worker @on_inner_monologue = on_inner_monologue @on_outer_voice = on_outer_voice @on_finish = on_finish end |
Instance Attribute Details
#on_finish ⇒ Object
Returns the value of attribute on_finish.
5 6 7 |
# File 'lib/oxaiworkers/image_iterator.rb', line 5 def on_finish @on_finish end |
#on_inner_monologue ⇒ Object
Returns the value of attribute on_inner_monologue.
5 6 7 |
# File 'lib/oxaiworkers/image_iterator.rb', line 5 def on_inner_monologue @on_inner_monologue end |
#on_outer_voice ⇒ Object
Returns the value of attribute on_outer_voice.
5 6 7 |
# File 'lib/oxaiworkers/image_iterator.rb', line 5 def on_outer_voice @on_outer_voice end |
#task ⇒ Object
Returns the value of attribute task.
5 6 7 |
# File 'lib/oxaiworkers/image_iterator.rb', line 5 def task @task end |
#worker ⇒ Object
Returns the value of attribute worker.
5 6 7 |
# File 'lib/oxaiworkers/image_iterator.rb', line 5 def worker @worker end |
Instance Method Details
#add_task(task) ⇒ Object
37 38 39 |
# File 'lib/oxaiworkers/image_iterator.rb', line 37 def add_task(task) @task = task end |
#cleanup ⇒ Object
33 34 35 |
# File 'lib/oxaiworkers/image_iterator.rb', line 33 def cleanup @worker.cleanup end |
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/oxaiworkers/image_iterator.rb', line 14 def execute response = @worker.client.images.generate( parameters: { prompt: @task, model: 'dall-e-3', size: '1024x1792', quality: 'standard' } ) url = response.dig('data', 0, 'url') puts url puts response.inspect @on_inner_monologue&.call(text: I18n.t('oxaiworkers.iterator.image_iterator.url', url:)) @on_outer_voice&.call(text: url) @on_finish&.call(result: url) response end |