Class: Slidict::Config
- Inherits:
-
Object
- Object
- Slidict::Config
- Defined in:
- lib/slidict/config.rb
Constant Summary collapse
- DEFAULT_MODEL =
"gpt-4o-mini"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(base_url: nil, api_key: nil, model: DEFAULT_MODEL, enabled: true) ⇒ Config
constructor
A new instance of Config.
-
#llm_enabled? ⇒ Boolean
An llm-base-url is required to enable the LLM call; otherwise the built-in slide template is used.
- #merge(base_url: nil, api_key: nil, model: nil, enabled: nil) ⇒ Object
Constructor Details
#initialize(base_url: nil, api_key: nil, model: DEFAULT_MODEL, enabled: true) ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 |
# File 'lib/slidict/config.rb', line 9 def initialize(base_url: nil, api_key: nil, model: DEFAULT_MODEL, enabled: true) @base_url = base_url @api_key = api_key @model = model @enabled = enabled end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/slidict/config.rb', line 7 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
7 8 9 |
# File 'lib/slidict/config.rb', line 7 def base_url @base_url end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/slidict/config.rb', line 7 def model @model end |
Class Method Details
.from_env(env = ENV) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/slidict/config.rb', line 16 def self.from_env(env = ENV) new( base_url: env["SLIDICT_LLM_BASE_URL"], api_key: env["SLIDICT_LLM_API_KEY"], model: env["SLIDICT_LLM_MODEL"] || DEFAULT_MODEL ) end |
Instance Method Details
#llm_enabled? ⇒ Boolean
An llm-base-url is required to enable the LLM call; otherwise the built-in slide template is used.
35 36 37 |
# File 'lib/slidict/config.rb', line 35 def llm_enabled? @enabled && !base_url.to_s.strip.empty? end |
#merge(base_url: nil, api_key: nil, model: nil, enabled: nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/slidict/config.rb', line 24 def merge(base_url: nil, api_key: nil, model: nil, enabled: nil) self.class.new( base_url: base_url || @base_url, api_key: api_key || @api_key, model: model || @model, enabled: enabled.nil? ? @enabled : enabled ) end |