Class: ConsoleAgent::Configuration
- Inherits:
-
Object
- Object
- ConsoleAgent::Configuration
- Defined in:
- lib/console_agent/configuration.rb
Constant Summary collapse
- PROVIDERS =
%i[anthropic openai].freeze
- PRICING =
{ 'claude-sonnet-4-6' => { input: 3.0 / 1_000_000, output: 15.0 / 1_000_000 }, 'claude-opus-4-6' => { input: 15.0 / 1_000_000, output: 75.0 / 1_000_000 }, 'claude-haiku-4-5-20251001' => { input: 0.80 / 1_000_000, output: 4.0 / 1_000_000 }, }.freeze
- DEFAULT_MAX_TOKENS =
{ 'claude-sonnet-4-6' => 16_000, 'claude-haiku-4-5-20251001' => 16_000, 'claude-opus-4-6' => 4_096, }.freeze
Instance Attribute Summary collapse
-
#admin_password ⇒ Object
Returns the value of attribute admin_password.
-
#admin_username ⇒ Object
Returns the value of attribute admin_username.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#authenticate ⇒ Object
Returns the value of attribute authenticate.
-
#auto_execute ⇒ Object
Returns the value of attribute auto_execute.
-
#connection_class ⇒ Object
Returns the value of attribute connection_class.
-
#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.
-
#session_logging ⇒ Object
Returns the value of attribute session_logging.
-
#storage_adapter ⇒ Object
Returns the value of attribute storage_adapter.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
-
#thinking_model ⇒ Object
Returns the value of attribute thinking_model.
-
#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_max_tokens ⇒ Object
- #resolved_model ⇒ Object
- #resolved_thinking_model ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/console_agent/configuration.rb', line 25 def initialize @provider = :anthropic @api_key = nil @model = nil @thinking_model = nil @max_tokens = nil @auto_execute = false @temperature = 0.2 @timeout = 30 @debug = false @max_tool_rounds = 200 @storage_adapter = nil @memories_enabled = true @session_logging = true @connection_class = nil @admin_username = nil @admin_password = nil @authenticate = nil end |
Instance Attribute Details
#admin_password ⇒ Object
Returns the value of attribute admin_password.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def admin_password @admin_password end |
#admin_username ⇒ Object
Returns the value of attribute admin_username.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def admin_username @admin_username end |
#api_key ⇒ Object
Returns the value of attribute api_key.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def api_key @api_key end |
#authenticate ⇒ Object
Returns the value of attribute authenticate.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def authenticate @authenticate end |
#auto_execute ⇒ Object
Returns the value of attribute auto_execute.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def auto_execute @auto_execute end |
#connection_class ⇒ Object
Returns the value of attribute connection_class.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def connection_class @connection_class end |
#debug ⇒ Object
Returns the value of attribute debug.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def debug @debug end |
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def max_tokens @max_tokens end |
#max_tool_rounds ⇒ Object
Returns the value of attribute max_tool_rounds.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def max_tool_rounds @max_tool_rounds end |
#memories_enabled ⇒ Object
Returns the value of attribute memories_enabled.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def memories_enabled @memories_enabled end |
#model ⇒ Object
Returns the value of attribute model.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def model @model end |
#provider ⇒ Object
Returns the value of attribute provider.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def provider @provider end |
#session_logging ⇒ Object
Returns the value of attribute session_logging.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def session_logging @session_logging end |
#storage_adapter ⇒ Object
Returns the value of attribute storage_adapter.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def storage_adapter @storage_adapter end |
#temperature ⇒ Object
Returns the value of attribute temperature.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def temperature @temperature end |
#thinking_model ⇒ Object
Returns the value of attribute thinking_model.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def thinking_model @thinking_model end |
#timeout ⇒ Object
Returns the value of attribute timeout.
17 18 19 |
# File 'lib/console_agent/configuration.rb', line 17 def timeout @timeout end |
Instance Method Details
#resolved_api_key ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/console_agent/configuration.rb', line 45 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_max_tokens ⇒ Object
67 68 69 70 71 |
# File 'lib/console_agent/configuration.rb', line 67 def resolved_max_tokens return @max_tokens if @max_tokens DEFAULT_MAX_TOKENS.fetch(resolved_model, 4096) end |
#resolved_model ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/console_agent/configuration.rb', line 56 def resolved_model return @model if @model && !@model.empty? case @provider when :anthropic 'claude-sonnet-4-6' when :openai 'gpt-5.3-codex' end end |
#resolved_thinking_model ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/console_agent/configuration.rb', line 73 def resolved_thinking_model return @thinking_model if @thinking_model && !@thinking_model.empty? case @provider when :anthropic 'claude-opus-4-6' when :openai 'gpt-5.3-codex' end end |
#validate! ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/console_agent/configuration.rb', line 84 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 |