Sha256: 648792d2a52b3345f3e87559fbcb30e00e3e532a81598e47c9e6efe18e74a034

Contents?: true

Size: 547 Bytes

Versions: 3

Compression:

Stored size: 547 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]
        response = open_ai_client.images.generate(parameters: { prompt: message, size: image_size })
        response = response.to_json
        if !response.json(:message).empty?
          return false, "*OpenAI*: #{response.json(:message)}"
        else
          urls = response.json(:url)
          return true, urls
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.15.25 lib/slack/smart-bot/ai/open_ai/send_image_generation.rb
slack-smart-bot-1.15.1 lib/slack/smart-bot/ai/open_ai/send_image_generation.rb
slack-smart-bot-1.15.0 lib/slack/smart-bot/ai/open_ai/send_image_generation.rb