Top Level Namespace

Constant Summary collapse

CONFIG_DIR =
Dir.home + '/.config/ruby-openai-cli'
CHATS_DIR =
CONFIG_DIR + '/chats'
API_KEY_FILE =
CONFIG_DIR + '/api_key'
CONTEXTS_FILE =
CONFIG_DIR + '/contexts.json'
MODEL =
'gpt-3.5-turbo'
DEFAULT_CONTEXTS =
{
  "ruby": 'Imagine you are a senior software developer specialized in Ruby, ' \
          'Ruby on Rails and SQL with 20 years of experience. ' \
          'You are very proficient at writing high quality, clean, concise and highly ' \
          'optimized code that follows the standards. You are my personal assistant. ' \
          'You are here to help me in various tasks and answer my questions.'
}
VERSION =
'1.0.2'

Instance Method Summary collapse

Instance Method Details

#format_input(input) ⇒ Object



65
66
67
68
# File 'lib/prompt.rb', line 65

def format_input(input)
  puts TTY::Markdown.parse("**Your message>**\n" + input + "\n",
                           theme: { strong: %i[yellow bold] })
end

#format_response(response) ⇒ Object



70
71
72
73
# File 'lib/prompt.rb', line 70

def format_response(response)
  puts TTY::Markdown.parse("\n**ChatGPT response:**\n" + response + "\n\n",
                           theme: { strong: %i[blue bold] })
end

#get_inputObject



60
61
62
63
# File 'lib/prompt.rb', line 60

def get_input
  printf TTY::Markdown.parse('**Your message>**', theme: { strong: %i[yellow bold] })
  gets.chomp
end