Sha256: b7c1723c62212abda582c74fbb1a36982863a98e4c15538e0ede93e65815ad7b

Contents?: true

Size: 579 Bytes

Versions: 3

Compression:

Stored size: 579 Bytes

Contents

class SlackSmartBot
  module AI
    module OpenAI
      def self.send_image_generation(open_ai_client, message, image_size)
        require "openai"
        user = Thread.current[:user]
        #todo: personal settings size #Jal
        response = open_ai_client.images.generate(parameters: { prompt: message, size: image_size })
        if !response.body.json(:message).empty?
          return false, "*OpenAI*: #{response.body.json(:message)}"
        else
          urls = [response.body.json(:url)].flatten
          return true, urls
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.14.2 lib/slack/smart-bot/ai/open_ai/send_image_generation.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/ai/open_ai/send_image_generation.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/ai/open_ai/send_image_generation.rb