Module: LLM::Utils

Extended by:
Utils
Included in:
Anthropic, Google, Utils
Defined in:
lib/llm/utils.rb

Overview

Shared utility methods used across the runtime.

Instance Method Summary collapse

Instance Method Details

#resolve_option(obj, option, resolve_symbol: true) ⇒ Object

Resolves a configured option against an object instance.

Proc values are evaluated with ‘instance_exec`, symbol values are optionally sent to the object as method calls, hashes are duplicated, and all other values are returned as-is.

Parameters:

  • obj (Object)
  • option (Object)
  • resolve_symbol (Boolean) (defaults to: true)

Returns:



20
21
22
23
24
25
26
27
# File 'lib/llm/utils.rb', line 20

def resolve_option(obj, option, resolve_symbol: true)
  case option
  when Proc then obj.instance_exec(&option)
  when Symbol then resolve_symbol ? obj.send(option) : option
  when Hash then option.dup
  else option
  end
end