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

#fetch(properties, name) ⇒ 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.



86
87
88
# File 'lib/llm/tool/param.rb', line 86

def fetch(properties, name)
  properties[name] || properties.fetch(name.to_s)
end

#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.



64
65
66
67
68
69
70
71
72
73
# File 'lib/llm/tool/param.rb', line 64

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.



75
76
77
78
79
80
81
82
83
84
# File 'lib/llm/tool/param.rb', line 75

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