Module: LLM::Tool::Param::Utils Private

Extended by:
Utils
Included in:
Utils
Defined in:
lib/llm/tool/param.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#resolve(schema, type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
55
56
57
58
59
# File 'lib/llm/tool/param.rb', line 50

def resolve(schema, type)
  if LLM::Schema::Leaf === type
    type
  elsif Class === type && type.respond_to?(:object)
    type.object
  else
    target = type.name.split("::").last.downcase
    schema.public_send(target)
  end
end

#setup(leaf, description, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



61
62
63
64
65
66
67
68
69
70
# File 'lib/llm/tool/param.rb', line 61

def setup(leaf, description, options)
  required = options.fetch(:required, false)
  default = options.fetch(:default, nil)
  enum = options.fetch(:enum, nil)
  leaf.required if required
  leaf.description(description) if description
  leaf.default(default) if default
  leaf.enum(*enum) if enum
  leaf
end