Class: Riffer::Providers::OpenAI
- Defined in:
- lib/riffer/providers/open_ai.rb
Instance Method Summary collapse
-
#initialize(**options) ⇒ OpenAI
constructor
Initializes the OpenAI provider.
Methods inherited from Base
find, #generate_text, identifier, #stream_text
Methods included from Messages::Converter
Constructor Details
#initialize(**options) ⇒ OpenAI
Initializes the OpenAI provider.
11 12 13 14 15 16 17 18 |
# File 'lib/riffer/providers/open_ai.rb', line 11 def initialize(**) depends_on "openai" api_key = .fetch(:api_key, Riffer.config.openai.api_key) raise Riffer::ArgumentError, "OpenAI API key is required. Set it via Riffer.configure or pass :api_key option" if api_key.nil? || api_key.empty? @client = ::OpenAI::Client.new(api_key: api_key, **.except(:api_key)) end |