Class: Mildred::Configuration
- Inherits:
-
Object
- Object
- Mildred::Configuration
- Defined in:
- lib/mildred/configuration.rb
Constant Summary collapse
- DEFAULTS =
{ "provider" => "ollama", "model" => "llama3.1:8b", "ollama_url" => "http://localhost:11434/v1" }.freeze
- CONFIG_DIR =
File.join(Dir.home, ".mildred")
- CONFIG_PATH =
File.join(CONFIG_DIR, "config.yml")
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
- #apply! ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 |
# File 'lib/mildred/configuration.rb', line 18 def initialize @settings = load_config @provider = @settings["provider"] @model = @settings["model"] end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
16 17 18 |
# File 'lib/mildred/configuration.rb', line 16 def model @model end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
16 17 18 |
# File 'lib/mildred/configuration.rb', line 16 def provider @provider end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
16 17 18 |
# File 'lib/mildred/configuration.rb', line 16 def settings @settings end |
Instance Method Details
#apply! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mildred/configuration.rb', line 24 def apply! config_data = @settings RubyLLM.configure do |config| case @provider when "ollama" config.ollama_api_base = config_data["ollama_url"] when "openai" config.openai_api_key = config_data["openai_api_key"] when "openrouter" config.openrouter_api_key = config_data["openrouter_api_key"] end config.default_model = @model end end |