Module: OpenAIPipe

Defined in:
lib/openai_pipe.rb,
lib/openai_pipe/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.4"

Class Method Summary collapse

Class Method Details

.exeObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/openai_pipe.rb', line 10

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