Class: ConsoleAgent::Configuration
- Inherits:
-
Object
- Object
- ConsoleAgent::Configuration
- Defined in:
- lib/console_agent/configuration.rb
Constant Summary collapse
- PROVIDERS =
i[anthropic openai].freeze
- CONTEXT_MODES =
i[full smart].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#auto_execute ⇒ Object
Returns the value of attribute auto_execute.
-
#context_mode ⇒ Object
Returns the value of attribute context_mode.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
-
#max_tool_rounds ⇒ Object
Returns the value of attribute max_tool_rounds.
-
#memories_enabled ⇒ Object
Returns the value of attribute memories_enabled.
-
#model ⇒ Object
Returns the value of attribute model.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#storage_adapter ⇒ Object
Returns the value of attribute storage_adapter.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #resolved_api_key ⇒ Object
- #resolved_model ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/console_agent/configuration.rb', line 11 def initialize @provider = :anthropic @api_key = nil @model = nil @max_tokens = 4096 @auto_execute = false @context_mode = :smart @temperature = 0.2 @timeout = 30 @debug = false @max_tool_rounds = 100 @storage_adapter = nil @memories_enabled = true end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def api_key @api_key end |
#auto_execute ⇒ Object
Returns the value of attribute auto_execute.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def auto_execute @auto_execute end |
#context_mode ⇒ Object
Returns the value of attribute context_mode.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def context_mode @context_mode end |
#debug ⇒ Object
Returns the value of attribute debug.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def debug @debug end |
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def max_tokens @max_tokens end |
#max_tool_rounds ⇒ Object
Returns the value of attribute max_tool_rounds.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def max_tool_rounds @max_tool_rounds end |
#memories_enabled ⇒ Object
Returns the value of attribute memories_enabled.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def memories_enabled @memories_enabled end |
#model ⇒ Object
Returns the value of attribute model.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def model @model end |
#provider ⇒ Object
Returns the value of attribute provider.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def provider @provider end |
#storage_adapter ⇒ Object
Returns the value of attribute storage_adapter.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def storage_adapter @storage_adapter end |
#temperature ⇒ Object
Returns the value of attribute temperature.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def temperature @temperature end |
#timeout ⇒ Object
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/console_agent/configuration.rb', line 6 def timeout @timeout end |
Instance Method Details
#resolved_api_key ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/console_agent/configuration.rb', line 26 def resolved_api_key return @api_key if @api_key && !@api_key.empty? case @provider when :anthropic ENV['ANTHROPIC_API_KEY'] when :openai ENV['OPENAI_API_KEY'] end end |
#resolved_model ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/console_agent/configuration.rb', line 37 def resolved_model return @model if @model && !@model.empty? case @provider when :anthropic 'claude-opus-4-6' when :openai 'gpt-5.3-codex' end end |
#validate! ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/console_agent/configuration.rb', line 48 def validate! unless PROVIDERS.include?(@provider) raise ConfigurationError, "Unknown provider: #{@provider}. Valid: #{PROVIDERS.join(', ')}" end unless resolved_api_key env_var = @provider == :anthropic ? 'ANTHROPIC_API_KEY' : 'OPENAI_API_KEY' raise ConfigurationError, "No API key. Set config.api_key or #{env_var} env var." end end |