Sha256: 39cd23d25808b9326ded329003ca29c73b472b653b5a741a71703a385ef9026b
Contents?: true
Size: 758 Bytes
Versions: 2
Compression:
Stored size: 758 Bytes
Contents
# frozen_string_literal: true module Please Request = Struct.new(:instruction, :codex_service, :context, keyword_init: true) do def send codex_service.completion(prompt) .strip # Collapse multiline commands into one line .gsub(/\s*\\\n\s*/, ' ') # Remove subsequent lines that do not contain commands .gsub(/\n[^\$][^\n]*$/, '') # Collapse multiple commands into one line .gsub(/\n\$ /, '; ') # Remove multiple consecutive spaces .gsub(/\s+/, ' ') end def prompt <<~PROMPT.chomp Write a one-line bash command for each of the following tasks. #{context.to_s} # #{instruction.gsub(/\n/, " ")} $ PROMPT end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openai-please-0.1.2 | lib/please/request.rb |
openai-please-0.1.1 | lib/please/request.rb |