Class: Mj::ChatGpt::ThorCommand
- Inherits:
-
Thor
- Object
- Thor
- Mj::ChatGpt::ThorCommand
- Defined in:
- lib/mj/chatgpt/thor_command.rb
Instance Method Summary collapse
Instance Method Details
#ask(question) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/mj/chatgpt/thor_command.rb', line 11 def ask(question) client_config = { access_token: ENV.fetch("OPENAI_ACCESS_TOKEN") } client = OpenAI::Client.new(**client_config.compact) handler = Commands::AskCommandHandler.new(client: client) data = handler.handle(Commands::AskCommand.new(question, options: )) $stdout.puts JSON.generate(data) end |