Module: QuickOpenAI::Dalle2
- Defined in:
- lib/quick_openai/dalle2.rb
Class Method Summary collapse
Class Method Details
.dalle2(prompt, **options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/quick_openai/dalle2.rb', line 5 def self.dalle2(prompt, **) parameters = { prompt: prompt, ** } response = QuickOpenAI.fetch_response_from_client do |client| client.images.generate(parameters: parameters) end results = response.fetch("data") tempfiles = results.map do |result| url = result["url"] Down.download(url) end if tempfiles.size == 1 tempfiles.first else tempfiles end end |