Sha256: e1de326d89326c2500070420d43b65c794a7312cf2c4c81a99bf1584abb47a3c

Contents?: true

Size: 445 Bytes

Versions: 5

Compression:

Stored size: 445 Bytes

Contents

# frozen_string_literal: true

require_relative "openai_pipe/version"

require "quick_openai"

module OpenAIPipe
  class Error < StandardError; end

  def self.exe
    input_from_pipe = $stdin.read if $stdin.stat.pipe?

    input_from_arguments = ARGV.join(" ") if ARGV.any?

    prompt = [input_from_arguments, input_from_pipe].compact.join("\n\n")

    puts prompt.gpt3
  rescue QuickOpenAI::Error => e
    warn e.message
    exit 1
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
openai_pipe-0.1.4 lib/openai_pipe.rb
openai_pipe-0.1.3 lib/openai_pipe.rb
openai_pipe-0.1.2 lib/openai_pipe.rb
openai_pipe-0.1.1 lib/openai_pipe.rb
openai_pipe-0.1.0 lib/openai_pipe.rb