Module: LLM::Tool::Param
- Included in:
- LLM::Tool
- Defined in:
- lib/llm/tool/param.rb
Overview
The LLM::Tool::Param module extends the LLM::Tool class with a “param” method that can define a parameter for simple types. For complex types, use LLM::Tool.params instead.
Defined Under Namespace
Modules: Utils
Instance Method Summary collapse
- #param(name, type, description, options = {}) ⇒ Object (also: #parameter)
-
#required(names) ⇒ LLM::Schema::Object
Mark existing parameters as required.
Instance Method Details
#param(name, type, description, options = {}) ⇒ Object Also known as: parameter
37 38 39 40 41 42 43 44 |
# File 'lib/llm/tool/param.rb', line 37 def param(name, type, description, = {}) lock do function.params do |schema| resolved = Utils.resolve(schema, type) schema.object(name => Utils.setup(resolved, description, )) end end end |
#required(names) ⇒ LLM::Schema::Object
Mark existing parameters as required.
51 52 53 54 55 56 57 |
# File 'lib/llm/tool/param.rb', line 51 def required(names) lock do function.params.tap do |schema| [*names].each { Utils.fetch(schema.properties, _1).required } end end end |