Class: Aiko::Config
- Inherits:
-
Object
- Object
- Aiko::Config
- Defined in:
- lib/aiko/config.rb
Constant Summary collapse
- DEFAULTS =
{ base_url: "https://api.deepseek.com", model: "deepseek-v4-flash", max_iterations: 20 }.freeze
- FILE_KEYS =
%w[base_url model max_iterations].freeze
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.
-
#max_iterations ⇒ Object
readonly
Returns the value of attribute max_iterations.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#workdir ⇒ Object
readonly
Returns the value of attribute workdir.
Class Method Summary collapse
- .default_config_path ⇒ Object
- .load(cli_options = {}, config_path: default_config_path, env: ENV) ⇒ Object
Instance Method Summary collapse
-
#initialize(api_key:, base_url:, model:, max_iterations:, workdir: nil) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(api_key:, base_url:, model:, max_iterations:, workdir: nil) ⇒ Config
Returns a new instance of Config.
45 46 47 48 49 50 51 52 |
# File 'lib/aiko/config.rb', line 45 def initialize(api_key:, base_url:, model:, max_iterations:, workdir: nil) @api_key = api_key @base_url = base_url @model = model @max_iterations = max_iterations @workdir = File.(workdir || Dir.pwd) validate! end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
15 16 17 |
# File 'lib/aiko/config.rb', line 15 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
15 16 17 |
# File 'lib/aiko/config.rb', line 15 def base_url @base_url end |
#max_iterations ⇒ Object (readonly)
Returns the value of attribute max_iterations.
15 16 17 |
# File 'lib/aiko/config.rb', line 15 def max_iterations @max_iterations end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
15 16 17 |
# File 'lib/aiko/config.rb', line 15 def model @model end |
#workdir ⇒ Object (readonly)
Returns the value of attribute workdir.
15 16 17 |
# File 'lib/aiko/config.rb', line 15 def workdir @workdir end |
Class Method Details
.default_config_path ⇒ Object
32 33 34 |
# File 'lib/aiko/config.rb', line 32 def self.default_config_path File.join(Dir.home, ".aiko", "config.json") end |
.load(cli_options = {}, config_path: default_config_path, env: ENV) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aiko/config.rb', line 17 def self.load( = {}, config_path: default_config_path, env: ENV) file = load_file(config_path) merged = DEFAULTS.dup FILE_KEYS.each do |key| merged[key.to_sym] = file[key] if file.key?(key) end merged[:base_url] = env["AIKO_BASE_URL"] if env["AIKO_BASE_URL"] merged[:model] = env["AIKO_MODEL"] if env["AIKO_MODEL"] merged[:api_key] = env["AIKO_API_KEY"] %i[api_key base_url model max_iterations workdir].each do |key| merged[key] = [key] if .key?(key) && ![key].nil? end new(**merged) end |