Class: RubyLLM::Tools::ProviderTools::Resolution

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/tools/provider_tools.rb

Overview

The result of resolving a chat's provider tools against a protocol's alias table: tool entries for the payload's tools slot, extra payload fields to merge, and request headers to add.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResolution

Returns a new instance of Resolution.



16
17
18
19
20
# File 'lib/ruby_llm/tools/provider_tools.rb', line 16

def initialize
  @tools = []
  @payload = {}
  @headers = {}
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



14
15
16
# File 'lib/ruby_llm/tools/provider_tools.rb', line 14

def headers
  @headers
end

#payloadObject (readonly)

Returns the value of attribute payload.



14
15
16
# File 'lib/ruby_llm/tools/provider_tools.rb', line 14

def payload
  @payload
end

#toolsObject (readonly)

Returns the value of attribute tools.



14
15
16
# File 'lib/ruby_llm/tools/provider_tools.rb', line 14

def tools
  @tools
end

Instance Method Details

#add(spec, options) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ruby_llm/tools/provider_tools.rb', line 22

def add(spec, options)
  entry = spec.is_a?(Proc) ? spec.call(options || {}) : merge_tool_options(spec, options)
  @tools << entry[:tool] if entry[:tool]
  merge_payload(entry[:payload]) if entry[:payload]
  merge_headers(entry[:headers]) if entry[:headers]
  self
end

#add_raw(hash) ⇒ Object



30
31
32
33
# File 'lib/ruby_llm/tools/provider_tools.rb', line 30

def add_raw(hash)
  @tools << hash
  self
end