railsjazz / ask_chatgpt

AI-Powered Assistant Gem right in your Rails console. Full power of ChatGPT in Rails
https://www.railsjazz.com/
MIT License
259 stars 13 forks source link

NoMethodError: undefined method `valid_encoding?' for nil:NilClass #2

Closed themasses closed 1 year ago

themasses commented 1 year ago

Great gem, but unfortunately every method throws a NoMethodError. API-key is configured.

~/src/railsapp on main !2 ?1 ❯ rails c -- --noautocomplete
Loading development environment (Rails 7.0.4.3)
irb(main):001:0> gpt.ask("how to convert xml to json?")
{:model=>"gpt-3.5-turbo",
 :messages=>
  [{:role=>"user",
    :content=>
     "I have a Ruby on Rails Application, Version 7.0.4.3, Ruby Version: 3.2.2, Database: db/development.sqlite3"},
   {:role=>"user", :content=>"how to convert xml to json?"}],
 :temperature=>0.1}
-
An error occurred when inspecting the object: #<NoMethodError: undefined method 'valid_encoding?' for nil:NilClass>
Result of Kernel#inspect: #<AskChatgpt::Executor:0x00000001072b1da0 @scope=[#<AskChatgpt::Prompts::App:0x00000001072b1d00 @str=nil>, #<AskChatgpt::Prompts::Question:0x00000001072b1990 @str="how to convert xml to json?">], @client=#<OpenAI::Client:0x00000001072b2098>>
=> 
irb(main):002:0>
igorkasyanchuk commented 1 year ago

today will be released a new version, even with more features

igorkasyanchuk commented 1 year ago

@themasses actually try now with a newer version. It also has more options for customization and you can define your own prompts

themasses commented 1 year ago

Awesome, works perfectly now! 😊

igorkasyanchuk commented 1 year ago

great. ps: check out our other https://www.railsjazz.com/opensource