Sha256: 541c994a234e719f17ac5e9b8f8d4bf98100f319ecb3dc03351982682209f08e

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

class SlackSmartBot
  module AI
    module OpenAI
      def self.send_image_variation(open_ai_client, image, variations, size: "")
        #todo: add size personal settings
        require "openai"
        user = Thread.current[:user]
        if size == ""
          response = open_ai_client.images.variations(parameters: { image: image, n: variations })
        else
          response = open_ai_client.images.variations(parameters: { image: image, n: variations, size: size })
        end
        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_variation.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/ai/open_ai/send_image_variation.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/ai/open_ai/send_image_variation.rb