Class: Senior::Configuration::OpenAI
- Inherits:
-
Object
- Object
- Senior::Configuration::OpenAI
- Defined in:
- lib/senior/configuration/open_ai.rb
Overview
Encapsulates the OpenAI configuration
Constant Summary collapse
- DEFAULT_API_VERSION =
The default OpenAI API version
'v1'
- DEFAULT_MAX_TOKENS =
The default maximum number of tokens to use in the OpenAI API request
1024
- DEFAULT_MODEL =
The default OpenAI model to use
'text-davinci-003'
- DEFAULT_N =
The default number of responses to generate
1
- DEFAULT_REQUEST_TIMEOUT =
The default maximum amount of time to wait for an OpenAI API request to complete
120
- DEFAULT_TEMPERATURE =
The default temperature to use in the OpenAI API request
0.7
- DEFAULT_URI_BASE =
The default OpenAI URI base
'https://api.openai.com/'
Instance Attribute Summary collapse
-
#access_token ⇒ String
Gets the OpenAI access token, raising an error if it is not set.
-
#api_version ⇒ String
The OpenAI API version.
-
#max_tokens ⇒ Integer
The maximum number of tokens to use in the OpenAI API request.
-
#model ⇒ String
The OpenAI model to use.
-
#n ⇒ Integer
The number of responses to generate.
-
#organization_id ⇒ String?
The OpenAI organization ID.
-
#request_timeout ⇒ Integer
The maximum amount of time to wait for an OpenAI API request to complete.
-
#temperature ⇒ Float
The temperature to use in the OpenAI API request.
-
#uri_base ⇒ String
The OpenAI URI base.
Instance Method Summary collapse
-
#initialize ⇒ OpenAI
constructor
Initializes a new instance of the OpenAI configuration for the Senior gem.
Constructor Details
#initialize ⇒ OpenAI
Initializes a new instance of the OpenAI configuration for the Senior gem
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/senior/configuration/open_ai.rb', line 116 def initialize @access_token = nil @api_version = DEFAULT_API_VERSION @max_tokens = DEFAULT_MAX_TOKENS @model = DEFAULT_MODEL @n = DEFAULT_N @organization_id = nil @request_timeout = DEFAULT_REQUEST_TIMEOUT @temperature = DEFAULT_TEMPERATURE @uri_base = DEFAULT_URI_BASE end |
Instance Attribute Details
#access_token ⇒ String
Gets the OpenAI access token, raising an error if it is not set
138 139 140 141 142 143 |
# File 'lib/senior/configuration/open_ai.rb', line 138 def access_token return @access_token if @access_token error_text = 'OpenAI access token missing! See https://github.com/wilsonsilva/senior#usage' raise ConfigurationError, error_text end |
#api_version ⇒ String
The OpenAI API version
25 26 27 |
# File 'lib/senior/configuration/open_ai.rb', line 25 def api_version @api_version end |
#max_tokens ⇒ Integer
The maximum number of tokens to use in the OpenAI API request
34 35 36 |
# File 'lib/senior/configuration/open_ai.rb', line 34 def max_tokens @max_tokens end |
#model ⇒ String
The OpenAI model to use
43 44 45 |
# File 'lib/senior/configuration/open_ai.rb', line 43 def model @model end |
#n ⇒ Integer
The number of responses to generate
52 53 54 |
# File 'lib/senior/configuration/open_ai.rb', line 52 def n @n end |
#organization_id ⇒ String?
The OpenAI organization ID
61 62 63 |
# File 'lib/senior/configuration/open_ai.rb', line 61 def organization_id @organization_id end |
#request_timeout ⇒ Integer
The maximum amount of time to wait for an OpenAI API request to complete
70 71 72 |
# File 'lib/senior/configuration/open_ai.rb', line 70 def request_timeout @request_timeout end |
#temperature ⇒ Float
The temperature to use in the OpenAI API request
79 80 81 |
# File 'lib/senior/configuration/open_ai.rb', line 79 def temperature @temperature end |
#uri_base ⇒ String
The OpenAI URI base
88 89 90 |
# File 'lib/senior/configuration/open_ai.rb', line 88 def uri_base @uri_base end |