Class: RLM::Limits
- Inherits:
-
Object
- Object
- RLM::Limits
- Defined in:
- lib/rlm/limits.rb
Constant Summary collapse
- INTEGER_DEFAULTS =
{ max_iterations: 8, max_llm_calls: 25, max_sub_lm_calls: 20, max_tool_calls: 20, max_runtime_seconds: 120, max_cost_cents: 100, max_input_bytes: 25 * 1024 * 1024, max_output_bytes: 1 * 1024 * 1024, max_stdout_bytes: 256 * 1024, max_files: 50, max_file_bytes: 25 * 1024 * 1024, max_recursion_depth: 1 }.freeze
- BUDGET_POLICIES =
%i[fail return_partial needs_review].freeze
- DEFAULT_POLICY =
:needs_review- DEFAULTS =
INTEGER_DEFAULTS.merge(on_budget_exceeded: DEFAULT_POLICY).freeze
Instance Method Summary collapse
-
#initialize(**overrides) ⇒ Limits
constructor
A new instance of Limits.
- #merge(**overrides) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(**overrides) ⇒ Limits
Returns a new instance of Limits.
27 28 29 30 31 32 33 34 35 |
# File 'lib/rlm/limits.rb', line 27 def initialize(**overrides) unknown = overrides.keys - DEFAULTS.keys raise ArgumentError, "Unknown limit keys: #{unknown.join(", ")}" if unknown.any? DEFAULTS.merge(overrides).each do |key, value| instance_variable_set("@#{key}", value) end validate! end |
Instance Method Details
#merge(**overrides) ⇒ Object
37 38 39 |
# File 'lib/rlm/limits.rb', line 37 def merge(**overrides) self.class.new(**to_h, **overrides) end |
#to_h ⇒ Object
41 42 43 |
# File 'lib/rlm/limits.rb', line 41 def to_h DEFAULTS.keys.to_h { |k| [k, public_send(k)] } end |