-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Hey there,
I've noticed an area that could be improved. When I started using the gem, I was calling chat_completion without specifying openai and it would throw an error at me. This is because it is expecting I use the OpenRouter option whereas I just wanted to use my OpenAI key.
config/initailizer/raix.rb
Raix.configure do |config|
config.openai_client = OpenAI::Client.new(access_token: ENV.fetch("OPENAI_API_KEY", nil))
end
irb(main):001* class ExampleSummarizer
irb(main):002* include Raix::ChatCompletion
irb(main):003> end
irb(main):004>
irb(main):005> ts = ExampleSummarizer.new
irb(main):006> ts.transcript << { user: "Hello, how are you?" }
irb(main):007> ts.chat_completion
(irb):7:in '<main>': undefined method 'complete' for nil (NoMethodError)
Raix.configuration.openrouter_client.complete(messages, model:, extras: params.compact, stream:)
After a bit of investigation I saw realized you need to pass in openai parameter to chat_completion to get it to go down the OpenAI only path.
Suggestion
I think it would be helpful to add documentation on how to setup with OpenAI only and update the code to read from the configuration for the openai model to use if none is defined. config.openai_model = 'gpt-4o-mini'. And/or raise an error before hitting the undefined method error.
Thanks a ton! Let me know if this makes sense or not. Happy to open a PR for this.