Class: RubyPi::LLM::OpenAI
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- RubyPi::LLM::OpenAI
- Defined in:
- lib/ruby_pi/llm/openai.rb
Overview
OpenAI provider implementation. Communicates with the OpenAI Chat Completions API to generate text completions, handle tool/function calls, and stream responses via Server-Sent Events.
Constant Summary collapse
- BASE_URL =
Base URL for the OpenAI API.
"https://api.openai.com"
Instance Attribute Summary
Attributes inherited from BaseProvider
#max_retries, #retry_base_delay, #retry_max_delay
Instance Method Summary collapse
-
#initialize(model: nil, api_key: nil, **options) ⇒ OpenAI
constructor
Creates a new OpenAI provider instance.
-
#model_name ⇒ String
Returns the OpenAI model identifier.
-
#provider_name ⇒ Symbol
Returns :openai as the provider identifier.
Methods inherited from BaseProvider
Constructor Details
#initialize(model: nil, api_key: nil, **options) ⇒ OpenAI
Creates a new OpenAI provider instance.
31 32 33 34 35 36 |
# File 'lib/ruby_pi/llm/openai.rb', line 31 def initialize(model: nil, api_key: nil, **) super(**) config = RubyPi.configuration @model = model || config.default_openai_model @api_key = api_key || config.openai_api_key end |
Instance Method Details
#model_name ⇒ String
Returns the OpenAI model identifier.
41 42 43 |
# File 'lib/ruby_pi/llm/openai.rb', line 41 def model_name @model end |
#provider_name ⇒ Symbol
Returns :openai as the provider identifier.
48 49 50 |
# File 'lib/ruby_pi/llm/openai.rb', line 48 def provider_name :openai end |