Class: Xeno::AgentConfig
- Inherits:
-
Object
- Object
- Xeno::AgentConfig
- Defined in:
- lib/xeno/agent_config.rb
Overview
Instance Method Summary collapse
-
#initialize ⇒ AgentConfig
constructor
A new instance of AgentConfig.
-
#limits(**caps) ⇒ Object
Per-agent token budgets, overriding the global config:.
-
#model(id = nil, **options) ⇒ Object
DSL setter and reader in one:
model "id", **optionsinside the block,config.modelafterwards. - #model_options ⇒ Object
- #resolved_model ⇒ Object
-
#token_limit(axis, global) ⇒ Object
The effective cap for one axis: agent override first (false = off), then the global config.
Constructor Details
#initialize ⇒ AgentConfig
Returns a new instance of AgentConfig.
16 17 18 19 20 |
# File 'lib/xeno/agent_config.rb', line 16 def initialize @model_id = nil @model_options = {} @limits = {} end |
Instance Method Details
#limits(**caps) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/xeno/agent_config.rb', line 30 def limits(**caps) unless caps.empty? unknown = caps.keys - %i[input_tokens output_tokens] raise ArgumentError, "unknown limit axes: #{unknown.join(', ')}" if unknown.any? @limits = @limits.merge(caps) end @limits end |
#model(id = nil, **options) ⇒ Object
DSL setter and reader in one: model "id", **options inside the block,
config.model afterwards.
50 51 52 53 54 55 56 |
# File 'lib/xeno/agent_config.rb', line 50 def model(id = nil, **) if id @model_id = id @model_options = end @model_id end |
#model_options ⇒ Object
58 59 60 |
# File 'lib/xeno/agent_config.rb', line 58 def @model_options end |
#resolved_model ⇒ Object
62 63 64 |
# File 'lib/xeno/agent_config.rb', line 62 def resolved_model @model_id || RubyLLM.config.default_model end |
#token_limit(axis, global) ⇒ Object
The effective cap for one axis: agent override first (false = off), then the global config. nil = unlimited.
42 43 44 45 46 |
# File 'lib/xeno/agent_config.rb', line 42 def token_limit(axis, global) return nil if @limits[axis] == false @limits.fetch(axis, nil) || global end |