Class: RubyLLM::Contract::Step::RunnerConfig

Inherits:
Data
  • Object
show all
Defined in:
lib/ruby_llm/contract/step/runner_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter

Returns:

  • (Object)

    the current value of adapter



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def adapter
  @adapter
end

#attachment_token_estimateObject (readonly)

Returns the value of attribute attachment_token_estimate

Returns:

  • (Object)

    the current value of attachment_token_estimate



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def attachment_token_estimate
  @attachment_token_estimate
end

#contract_definitionObject (readonly)

Returns the value of attribute contract_definition

Returns:

  • (Object)

    the current value of contract_definition



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def contract_definition
  @contract_definition
end

#extra_optionsObject (readonly)

Returns the value of attribute extra_options

Returns:

  • (Object)

    the current value of extra_options



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def extra_options
  @extra_options
end

#input_typeObject (readonly)

Returns the value of attribute input_type

Returns:

  • (Object)

    the current value of input_type



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def input_type
  @input_type
end

#max_costObject (readonly)

Returns the value of attribute max_cost

Returns:

  • (Object)

    the current value of max_cost



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def max_cost
  @max_cost
end

#max_inputObject (readonly)

Returns the value of attribute max_input

Returns:

  • (Object)

    the current value of max_input



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def max_input
  @max_input
end

#max_outputObject (readonly)

Returns the value of attribute max_output

Returns:

  • (Object)

    the current value of max_output



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def max_output
  @max_output
end

#modelObject (readonly)

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def model
  @model
end

#observersObject (readonly)

Returns the value of attribute observers

Returns:

  • (Object)

    the current value of observers



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def observers
  @observers
end

#on_unknown_attachment_sizeObject (readonly)

Returns the value of attribute on_unknown_attachment_size

Returns:

  • (Object)

    the current value of on_unknown_attachment_size



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def on_unknown_attachment_size
  @on_unknown_attachment_size
end

#on_unknown_pricingObject (readonly)

Returns the value of attribute on_unknown_pricing

Returns:

  • (Object)

    the current value of on_unknown_pricing



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def on_unknown_pricing
  @on_unknown_pricing
end

#output_schemaObject (readonly)

Returns the value of attribute output_schema

Returns:

  • (Object)

    the current value of output_schema



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def output_schema
  @output_schema
end

#output_typeObject (readonly)

Returns the value of attribute output_type

Returns:

  • (Object)

    the current value of output_type



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def output_type
  @output_type
end

#prompt_blockObject (readonly)

Returns the value of attribute prompt_block

Returns:

  • (Object)

    the current value of prompt_block



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def prompt_block
  @prompt_block
end

#temperatureObject (readonly)

Returns the value of attribute temperature

Returns:

  • (Object)

    the current value of temperature



6
7
8
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 6

def temperature
  @temperature
end

Class Method Details

.build(input_type:, output_type:, prompt_block:, contract_definition:, adapter:, model:, output_schema: nil, max_output: nil, max_input: nil, max_cost: nil, on_unknown_pricing: :refuse, attachment_token_estimate: nil, on_unknown_attachment_size: :refuse, temperature: nil, extra_options: {}, observers: []) ⇒ Object

Factory with sensible defaults for optional fields. Lets callers (Step::Base#run_once and tests) construct a RunnerConfig without repeating the 11-default boilerplate, and gives ‘Runner.new(config:)` a clean entry point for the value-object form.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 28

def self.build(input_type:, output_type:, prompt_block:, contract_definition:,
               adapter:, model:,
               output_schema: nil, max_output: nil,
               max_input: nil, max_cost: nil, on_unknown_pricing: :refuse,
               attachment_token_estimate: nil, on_unknown_attachment_size: :refuse,
               temperature: nil, extra_options: {}, observers: [])
  new(
    input_type: input_type, output_type: output_type,
    prompt_block: prompt_block, contract_definition: contract_definition,
    adapter: adapter, model: model,
    output_schema: output_schema, max_output: max_output,
    max_input: max_input, max_cost: max_cost,
    on_unknown_pricing: on_unknown_pricing,
    attachment_token_estimate: attachment_token_estimate,
    on_unknown_attachment_size: on_unknown_attachment_size,
    temperature: temperature, extra_options: extra_options,
    observers: observers
  )
end

Instance Method Details

#adapter_optionsObject



52
53
54
55
56
57
58
59
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 52

def adapter_options
  { model: model }.tap do |options|
    options[:schema] = output_schema if output_schema
    options[:max_tokens] = effective_max_output if effective_max_output
    options[:temperature] = temperature if temperature
    extra_options.each { |key, value| options[key] = value unless options.key?(key) }
  end
end

#effective_max_outputObject



48
49
50
# File 'lib/ruby_llm/contract/step/runner_config.rb', line 48

def effective_max_output
  extra_options[:max_tokens] || max_output
end